4 ms·
There is also SnapKit which I really like: https://github.com/SnapKit/SnapKit https://github.com/SnapKit/SnapKit box.snp_makeConstraints { (make) -> V
by msoad 11y ago
There is also SnapKit which I really like:
https://github.com/SnapKit/SnapKit https://github.com/SnapKit/SnapKit
box.snp_makeConstraints { (make) -> Void in
make.width.height.equalTo(50)
make.center.equalTo(self.view)
}
- aaronbrethorst 11y agoAnd Masonry, if you're still on Obj-C (like me): https://github.com/SnapKit/Masonry https://github.com/SnapKit/Masonry [box mas_makeConstraints:^(MASConstraintMaker* make) { make.width.height.equalTo(50); make.center.equalTo(self.view); }];
- RussianCow 11y agoAnd cartography, which is my preference: https://github.com/robb/Cartography https://github.com/robb/Cartography constrain(button1, button2) { button1, button2 in button1.right == button2.left - 12 }
- bdarnell 11y agoOr while we're sharing, here's mine in Obj-C++ (although I never managed to extract it into a separate package): https://github.com/viewfinderco/viewfinder/blob/master/clients/ios/Source/UIView+constraints.h https://github.com/viewfinderco/viewfinder/blob/master/clien... [self addConstraints:box.anchorWidth == 50]; [self addConstraints:box.anchorHeight == 50]; [self addConstraints:box.anchorCenterX == self.view.anchorCenterX]; [self addConstraints:box.anchorCenterY == self.view.anchorCenterY];
- mbenjaminsmith 11y agoCame here to say the same thing. I've abandoned storyboards and nibs in favor of SnapKit and it hasn't let me down so far. It's one of the better libraries I've used on OS X and iOS.
- thought_alarm 11y agoOr use NSLayoutAnchor, which was added in iOS 9 and OS X 10.10; [box.widthAnchor constraintEqualToConstant:50].active = YES; [box.centerAnchor constrantEqualToAnchor:self.view.centerAnchor].active = YES;