Skip to content

OliveTreeBible/UIView-Positioning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UIView-Positioning

Auto Layout is the recommended way to do view layout on iOS. But there are times when it doesn't fit what you want to do. This is a handy category to abstract away all the pixel math involved in positioning views as desired.

All methods use the frame of the passed view to calculate position. Method names should be self-explanatory. centerSubview... or placeSubview... acts on a view assumed to be a subview of the view you're calling the method on. centerSiblingView... acts on a view assumed to be a sibling (has the same superview) of the view you're calling the method on. And all methods pin to physical pixels on all devices.

This does not explicitly interact with Auto Layout. It simply calls setFrame. If you're having issues with views not going where you expect them and Auto Layout is involved, you should take a look at the WWDC 2015 sessions "Mysteries of Auto Layout" Part 1 (session 218) and Part 2 (session 219).

About

A category on UIView for when Auto Layout isn't quite right.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published