mthongvanh / CHAAutolayoutCategories

A custom UIView category that implements auto layout convenience methods

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CHAAutolayoutCategories

A custom UIView category that implements auto layout convenience methods

How to create constraints

[self.view addSubview:self.profilePicture];

const CGFloat defaultOffset = 10.f;

NSLayoutConstraint *leading = [self.profilePicture pinLeading:defaultOffset];
NSLayoutConstraint *centerY = [self.profilePicture alignCenterVerticalSuperview];
NSLayoutConstraint *aspectRatio = [self.profilePicture aspectRatio];
NSLayoutConstraint *heightMax = [self.profilePicture height:NSLayoutRelationEqual multiplier:0.35f];
NSLayoutConstraint *top = [self.profilePicture pinSide:NSLayoutAttributeTop relation:NSLayoutRelationGreaterThanOrEqual constant:defaultOffset];

[self.profilePicture.superview addConstraints:@[leading,centerY,aspectRatio,heightMax,top]];

About

A custom UIView category that implements auto layout convenience methods


Languages

Language:Objective-C 100.0%