Created
December 14, 2016 22:53
-
-
Save nevyn/0b097b4e661c50217e20d64b2ea8db76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LBNotificationBanner *banner = [LBNotificationBanner new]; | |
[overlay addSubview:banner]; | |
banner.translatesAutoresizingMaskIntoConstraints = NO; | |
LBInstallConstraint(banner, Top, Equal, overlay, Top, 1, margin); | |
LBInstallConstraint(banner, Left, Equal, overlay, Left, 1, margin); | |
LBInstallConstraint(banner, Right, Equal, overlay, Right, 1, margin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LBConstraint(view1, attr1, relation, view2, attr2, mul, const) [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttribute ## attr1 relatedBy: NSLayoutRelation ## relation toItem:view2 attribute: NSLayoutAttribute ## attr2 multiplier:mul constant:const] | |
#define LBInstallConstraint(view1, attr1, relation, view2, attr2, mul, const) ({id constraint = LBConstraint(view1, attr1, relation, view2, attr2, mul, const); [view2 addConstraint:constraint]; constraint; }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// equivalent in Masonry | |
[banner makeConstraints:^(Maker *make) { make.top.equalTo(overlay.mas_top).with.offset(20); } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment