MCUIViewLayout
MCUIViewLayout is a category added over UIView to make layouting the views easier. It provide shortcut methods to set width, height, position based without the need to always resort to using CGGeometry functions.
Using
All methods are prefixed mc_
at the moment. This is to avoid colisions as described in
Programming with Objective-C.
Change z-ordering of a view
You've just added a view and need it bellow all other views or the other way
around? Don't need to play with the subviews
array of the superview
.
Managing the size of the view
Using setFrame:
or setBounds:
just to change the size is a pain because
one need to preserve positioning. Here are some convinience methods to do so.
Absolute positioning
Using setFrame:
or setBounds:
just to change the position is wonky because
one needs to preserve the size.
Positioning in superview
Or if you prefer being more specific about your positions use MCViewPosition and
UIEdgeInsets
thanks to UIEdgeInsetMake(top,left,bottom,right)
and UIEdgeInsetZero
The different MCViewPosition options:
Positioning view relative to other views
For all relative view positioning options
And more...
Not all the positioning methods are described here. This is still a work in progress. Find all the positiong methods in
UIView+MCLayout.h
.
Adding to your project
If you're using CocoaPods
, there's nothing simpler.
Add the following to your Podfile
and run pod install
pod 'MCUIViewLayout', :git => 'https://github.com/mirego/MCUIViewLayout.git'
Don't forget to #import "UIView+MCLayout.h"
where it's needed.