CocoaPods trunk is moving to be read-only. Read more on the blog, there are 8 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Apr 2015 |
Maintained by Moicci.
BYViewConstraint is covenient class to implement the "Auto Layout" in Objective-C as below.
UILabel* topLabel = [self addLabel:@"fullWidth/top" backColor:[UIColor redColor]];
UILabel* bottomLabel = [self addLabel:@"fullWidth/bottom" backColor:[UIColor redColor]];
UILabel* centerLabel = [self addLabel:@"centerX/Y" backColor:[UIColor blueColor]];
UILabel* leftLabel = [self addLabel:@"left" backColor:[UIColor greenColor]];
UILabel* rightLabel = [self addLabel:@"right" backColor:[UIColor greenColor]];
BYViewConstraint* constraint = [[BYViewConstraint alloc] initWithSuperview:self.view];
[constraint view:topLabel];
[constraint fullWidth];
[constraint top];
[constraint height:50];
[constraint view:bottomLabel];
[constraint fullWidth];
[constraint bottom];
[constraint height:50];
[constraint view:centerLabel];
[constraint centerX];
[constraint centerY];
[constraint width:150];
[constraint height:150];
[constraint view:leftLabel];
[constraint attachTop:topLabel];
[constraint attachBottom:bottomLabel];
[constraint left];
[constraint attachRight:centerLabel];
[constraint view:rightLabel];
[constraint attachTop:topLabel];
[constraint attachBottom:bottomLabel];
[constraint attachLeft:centerLabel];
[constraint right];
[constraint apply];Or in Swift.
let topLabel = addLabel("fullWidth/top", backColor:UIColor.redColor())
let bottomLabel = addLabel("fullWidth/bottom", backColor:UIColor.redColor())
let centerLabel = addLabel("centerX/Y", backColor:UIColor.blueColor())
let leftLabel = addLabel("left", backColor:UIColor.greenColor())
let rightLabel = addLabel("right", backColor:UIColor.greenColor())
let constraint = BYViewConstraint(superview:self.view)
constraint.view(topLabel)
.fullWidth()
.top()
.height(50)
constraint.view(bottomLabel)
.fullWidth()
.bottom()
.height(50)
constraint.view(centerLabel)
.centerX()
.centerY()
.width(150)
.height(150)
constraint.view(leftLabel)
.attachTop(topLabel)
.attachBottom(bottomLabel)
.left()
.attachRight(centerLabel)
constraint.view(rightLabel)
.attachTop(topLabel)
.attachBottom(bottomLabel)
.attachLeft(centerLabel)
.right()
constraint.apply()To run the example project, clone the repo, and run pod install from the Example directory first.
If you install this library by CocoaPods, clone the repo from https://github.com/moicci/BYViewConstraint for the Example.
then install the pod.
pod install
import "BYViewConstraint.h" into your Objective-C bridging header file (-Bridging-Header.h).#import "BYViewConstraint.h" in your .m file using BYViewConstraint.Moicci at bylo media inc.
BYViewConstraint is available under the MIT license. See the LICENSE file for more info.