| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- //
- // UIView+Layout.m
- // FLEX
- //
- // Created by Tanner Bennett on 7/18/19.
- //Copyright © 2019 Flipboard. All rights reserved.
- //
- #import "UIView+Layout.h"
- @implementation UIView (Layout)
- - (void)centerInView:(UIView *)view {
- [self.centerXAnchor constraintEqualToAnchor:view.centerXAnchor].active = YES;
- [self.centerYAnchor constraintEqualToAnchor:view.centerYAnchor].active = YES;
- }
- - (void)pinEdgesTo:(UIView *)view {
- [self.topAnchor constraintEqualToAnchor:view.topAnchor].active = YES;
- [self.leftAnchor constraintEqualToAnchor:view.leftAnchor].active = YES;
- [self.bottomAnchor constraintEqualToAnchor:view.bottomAnchor].active = YES;
- [self.rightAnchor constraintEqualToAnchor:view.rightAnchor].active = YES;
- }
- - (void)pinEdgesTo:(UIView *)view withInsets:(UIEdgeInsets)i {
- [self.topAnchor constraintEqualToAnchor:view.topAnchor constant:i.top].active = YES;
- [self.leftAnchor constraintEqualToAnchor:view.leftAnchor constant:i.left].active = YES;
- [self.bottomAnchor constraintEqualToAnchor:view.bottomAnchor constant:-i.bottom].active = YES;
- [self.rightAnchor constraintEqualToAnchor:view.rightAnchor constant:-i.right].active = YES;
- }
- - (void)pinEdgesToSuperview {
- [self pinEdgesTo:self.superview];
- }
- - (void)pinEdgesToSuperviewWithInsets:(UIEdgeInsets)insets {
- [self pinEdgesTo:self.superview withInsets:insets];
- }
- @end
|