iOS 6 auto layout is pretty handy. However, the auto-generated frames may have non-integral values. How can I force integer output for final frame positions and size using auto layout?
Auto Layout asks your controls how big they need to be and lays out the screen based on that information. Usually, you want to use the intrinsic content size, but there are some cases where you may not want to do that. In these cases, you can set an explicit width or height constraint on a view.
Auto layout is a property you can add to frames and components. It lets you create designs that grow to fill or shrink to fit, and reflow as their contents change. This is great when you need to add new layers, accommodate longer text strings, or maintain alignment as your designs evolve.
The constraints will make sure that your views adjust to any size changes without having to manually update frames or positions.
AutoLayout is smarter than you think.
While it's true that auto-generated frames can have fractional values, they ARE rounded to match the device's pixel ratio. On devices with Retina display (2x), fractions of 0.5 are allowed. On older devices, there don't seem to be any fractional values at all.
This means that you'll always get a pixel-perfect layout.
Took me quite a while to figure this out though. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With