Dev Juice: Help me fix my UIView animations
Dear Dev Juice,
I'm having an issue with UIView animations, that I'm struggling to describe in keywords, so I can't find anything helpful with Google. The problem is that I can't seem to work out how to make a UIButton move relative to the bottom of the parent view, as I shrink the parent view.
I've managed to get the other views inside the parent to scale with an autoresize mask, but I cannot for the life of me work out how to make the bottom (or even center) of my button clip on to the bounds of the view.
Not sure if that accurately paints the picture, and I'm not sure if it's relevant, but I'm making a widget for NotificationCenter. Hope you can help, I'm tearing my hair out.
Thanks,
Rory W.

Dear Rory,
It's still the autoresizing mask you have to deal with, but you need to be working with the struts instead of the springs.
The Autosizing pane in Interface Builder lets you establish a fixed distance between a view and its parent's edge. Imagine setting a view at 40 points from the top and left of the superview. Enabling the top and left struts in the inspector fixes that view at its relative position. When you use a right or bottom strut, those distances are also maintained. The view must either move or resize to stay the same distances from those sides.
The equivalents of struts in code are UIViewAutoresizingFlexibleLeftMargin, UIViewAutoresizingFlexibleRightMargin, UIViewAutoresizingFlexibleTopMargin, and UIViewAutoresizingFlexibleBottomMargin.
These flags allow a view to resize by expanding or shrinking in the direction of a given margin without affecting the size of any items inside. Although each of these correspond to the struts of Interface Builder's Autosizing pane, they act in the opposite way. In IB, struts fix the margins; the flags allow flexible resizing along those margins.
Enjoy your afternoon sip of Dev Juice!
Share
Source: http://tuaw.com/tag/devjuice
Categories
Struts vs springs in UIButton
Add a Comment
I love reading the good words of the doctor here, Erica Sadun. I study, read, code, and design to be able to talk the code someday like you do. Keep talking, you make hard code fun.
June 21 2011 at 11:58 PM Report abuse Permalink rate up rate down ReplyWait, you can make Notification Center widgets? How?
June 21 2011 at 9:40 PM Report abuse Permalink rate up rate down ReplyYeah, Notification center has a plugin interface, like many other Apple built-in iOS features (such as Lock Screen plugins). They haven't provided a public SDK for it, so making a widget is a jailbreak-only thing. Documentation for it is available on the web in places. See http://www.jailbreaknation.com/top-notification-center-jailbreak-widgets/
June 22 2011 at 2:13 PM Report abuse Permalink rate up rate down ReplyCan we haz TUAW Dev Juice shirts made? Please?
June 21 2011 at 9:13 PM Report abuse Permalink rate up rate down ReplyDeals of the Day
more deals- Acoustic Research Digital Photo Frame with iPod Dock for $50 + free shipping
- Targus Truss Case for iPad and iPad 2 for $15 + free shipping
- Apple iPhone 4 8GB for Verizon, AT&T, or Sprint for $50 + pickup at Best Buy
- Unlocked iPhone 4S 16GB for GSM (AT&T, T-Mobile) for $619 + free shipping
- Apple iMac Core i7 Quad 3.4GHz 27" w/ 24GB RAM, 2TB HDD for $2,677 + $29 s&h
- Used Apple Magic Mouse for $36 + $4 s&h
4 Comments