Creating an Interface Builder Style Autosizing Animation
Sunday, March 29th, 2009Configuring view autosizing in Apple’s Interface Builder is greatly aided by an animated view that shows how the currently selected element will resize with respect to it’s parent. In the yet to be released version of SunFlower I am planning on using a similar animation to make the anchor corner property of exclusion filters more intuitive. This article is about copying that Interface Builder UI element.

Attempt 1
My first attempt was unsuccessful. I attempted to use two layers and constraints. When I automated the bounds of the parent layer the sublayer only moved on the Y axis and did not move on the X axis.
Download the kode.
Attempt 2
After must chagrin I solved the problem. Instead of using two layers and constraints the kode was changed to use one layer. The resizing white rectangle is still a core animation layer but the red square was is now image content. The red square is anchored to the corner using the contentsgravity property.
Download the kode. (If you click on the view the red square will cycle the corner it is anchored to.)
I am still curious to know if it is possible to solve this problem with the two layer constraint method; if you know how, then please drop me a line.



