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.
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!
Subscribe to Newsletter
Software Updatesmore updates
- NFL Mobile updated for 2014 Season with new Fantasy Football features, NFL Now integration
- Yahoo Mail improves email inbox searching with new filtering options
- Ember for Mac gains 'hugely-requested' screen recording feature
- Spotify update adds equalizer, refreshed Artist page and more
- Fantastical 2.1 for iOS adds new snooze, search and notification features
- ExpanDrive 4, more services and faster sync