TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2015 |
Maintained by Arthur Ariel Sabintsev.
A small Objective-C category on UIView
that creates a UIView object that is ready to be used for programmatic AutoLayout. This class is useful for those of us who do a lot of our AutoLayout definitions outside of xibs and storyboards.
Simply drop the UIView+AutoLayoutView folder into your project, and reference UIView+AutoLayoutView.h
in the classes that need access to the information it provides.
@interface UIView (AutoLayoutView)
+ (instancetype)newAutoLayoutView;
+ (void)updateLayoutForView:(UIView *)view;
@end
+ (instancetype)newAutoLayoutView
{
UIView *view = [self new];
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
return view;
}
+ (void)updateLayoutForView:(UIView *)view
{
[view setNeedsLayout];
[view layoutIfNeeded];
}
@end
// Create an AutoLaoyut view
MyView *myView = [MyView autoLayoutNew]; // Creates a new progrmmatic-AutoLayout ready object
// Update the view after the constraints are set
[UIView updateLayoutForView:myView];
// Create an AutoLaoyut view
let myView = MyView.autoLayoutNew() // Creates a new progrmmatic-AutoLayout ready object
// Update the view after the constraints are set
UIView.updateLayoutForView(myView);