Skip to content

Instantly share code, notes, and snippets.

@nevyn
Created December 14, 2016 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevyn/0b097b4e661c50217e20d64b2ea8db76 to your computer and use it in GitHub Desktop.
Save nevyn/0b097b4e661c50217e20d64b2ea8db76 to your computer and use it in GitHub Desktop.
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);
#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; })
// 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