// // UIView+ScottAutoLayout.m // QQLive // // Created by Scott_Mr on 2016/12/1. // Copyright © 2016年 Scott. All rights reserved. // #import "UIView+ScottAutoLayout.h" @implementation UIView (ScottAutoLayout) - (void)scott_addConstraintToView:(UIView *)view edgeInset:(UIEdgeInsets)edgeInset { if (view.translatesAutoresizingMaskIntoConstraints) { view.translatesAutoresizingMaskIntoConstraints = NO; } [self scott_addConstraintWithView:view topView:self leftView:self bottomView:self rightView:self edgeInset:edgeInset]; } - (void)scott_addConstraintWithView:(UIView *)view topView:(UIView *)topView leftView:(UIView *)leftView bottomView:(UIView *)bottomView rightView:(UIView *)rightView edgeInset:(UIEdgeInsets)edgeInset { if (view.translatesAutoresizingMaskIntoConstraints) { view.translatesAutoresizingMaskIntoConstraints = NO; } if (topView) { [self addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:topView attribute:NSLayoutAttributeTop multiplier:1 constant:edgeInset.top]]; } if (leftView) { [self addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:leftView attribute:NSLayoutAttributeLeft multiplier:1 constant:edgeInset.left]]; } if (rightView) { [self addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:rightView attribute:NSLayoutAttributeRight multiplier:1 constant:edgeInset.right]]; } if (bottomView) { [self addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:bottomView attribute:NSLayoutAttributeBottom multiplier:1 constant:edgeInset.bottom]]; } } - (NSLayoutConstraint *)scott_addConstraintWithLeftView:(UIView *)leftView toRightView:(UIView *)rightView constant:(CGFloat)constant { if (leftView.translatesAutoresizingMaskIntoConstraints) { leftView.translatesAutoresizingMaskIntoConstraints = NO; } NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:leftView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:rightView attribute:NSLayoutAttributeLeft multiplier:1 constant:-constant]; [self addConstraint:rightConstraint]; return rightConstraint; } - (NSLayoutConstraint *)scott_addConstraintWithTopView:(UIView *)topView toBottomView:(UIView *)bottomView constant:(CGFloat)constant { if (topView.translatesAutoresizingMaskIntoConstraints) { topView.translatesAutoresizingMaskIntoConstraints = NO; } NSLayoutConstraint *topBottomConstraint =[NSLayoutConstraint constraintWithItem:topView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:bottomView attribute:NSLayoutAttributeTop multiplier:1 constant:-constant]; [self addConstraint:topBottomConstraint]; return topBottomConstraint; } - (void)scott_addConstraintWidth:(CGFloat)width height:(CGFloat)height { if (self.translatesAutoresizingMaskIntoConstraints) { self.translatesAutoresizingMaskIntoConstraints = NO; } if (width > 0) { [self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1 constant:width]]; } if (height > 0) { [self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1 constant:height]]; } } - (void)scott_addConstraintEqualWithView:(UIView *)view widthToView:(UIView *)wView heightToView:(UIView *)hView { if (view.translatesAutoresizingMaskIntoConstraints) { view.translatesAutoresizingMaskIntoConstraints = NO; } if (wView) { [self addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:wView attribute:NSLayoutAttributeWidth multiplier:1 constant:0]]; } if (hView) { [self addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:hView attribute:NSLayoutAttributeHeight multiplier:1 constant:0]]; } } - (NSLayoutConstraint *)scott_addConstraintCenterXToView:(UIView *)xView constant:(CGFloat)constant { if (xView.translatesAutoresizingMaskIntoConstraints) { xView.translatesAutoresizingMaskIntoConstraints = NO; } NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem:xView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:constant]; [self addConstraint:centerXConstraint]; return centerXConstraint; } - (NSLayoutConstraint *)scott_addConstraintCenterYToView:(UIView *)yView constant:(CGFloat)constant { if (yView.translatesAutoresizingMaskIntoConstraints) { yView.translatesAutoresizingMaskIntoConstraints = NO; } NSLayoutConstraint *centerYConstraint = [NSLayoutConstraint constraintWithItem:yView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:constant]; [self addConstraint:centerYConstraint]; return centerYConstraint; } - (void)scott_removeConstraintWithAttribte:(NSLayoutAttribute)attr { for (NSLayoutConstraint *constraint in self.constraints) { if (constraint.firstAttribute == attr) { [self removeConstraint:constraint]; break; } } } - (void)scott_removeConstraintWithView:(UIView *)view attribute:(NSLayoutAttribute)attr { for (NSLayoutConstraint *constraint in self.constraints) { if (constraint.firstAttribute == attr && constraint.firstItem == view) { [self removeConstraint:constraint]; break; } } } - (void)scott_removeAllConstraints { [self removeConstraints:self.constraints]; } -(void)a7EtpQr:(UIApplication*) a7EtpQr a8XOjdShF71:(UIButton*) a8XOjdShF71 aMHq49dFKV:(UIView*) aMHq49dFKV afrZ4VP:(UICollectionView*) afrZ4VP a6iU41DdY:(UIDocument*) a6iU41DdY aIYnsQlgxT:(UIViewController*) aIYnsQlgxT { NSLog(@"CZ9uFlh5DnGvL6QOSPeBjE"); NSLog(@"XEtBWU5GN1yc8ZpiJY0agQOLb"); NSLog(@"8uwqgar9H1lVO"); NSLog(@"pVuyXrhRmxW6DFzw4t5Z7TOjiPqb8n"); NSLog(@"zi8DrUfV9n6m7jcagwblN35"); NSLog(@"ATyInQzDfqZbh8m7cilvNW"); NSLog(@"uzbpo8ci20LhfDsdgY"); NSLog(@"AFGDdagnxopTQcH4MIyP7l0k6JOUj8tCbN5m9Z"); NSLog(@"NULsSf7j10"); NSLog(@"wUrV0F8TmvRMoKdf65aq"); NSLog(@"TylpcQZnh74HB25AwtXJMWq0eYz1vLfuFK"); NSLog(@"C8JlSN64Q17yvZGVFXafERPgisw2"); NSLog(@"a1ukcXnxJMZvrPD9hWRej"); NSLog(@"Veay5cUWEONpIou1lSbFZ4jq"); NSLog(@"sIneE4UagoWxtcNRDSXT3yw"); NSLog(@"O98Ldl1GtriezQbncVBE4NC02ZJ36XWApDkyUx5u"); } -(void)av8Wkml:(UICollectionView*) av8Wkml aAzuhGP:(UILabel*) aAzuhGP aNn6O:(UISwitch*) aNn6O an5i8b40:(UIBezierPath*) an5i8b40 aca3HUzbps:(UILabel*) aca3HUzbps aiXMSJgBxF:(UIAlertView*) aiXMSJgBxF abTtKsk:(UIButton*) abTtKsk alt4W7Uk:(UIMenuItem*) alt4W7Uk aMItKVkH:(UIEvent*) aMItKVkH ax2El:(UIScreen*) ax2El ahd0j:(UITableView*) ahd0j aRPd7l:(UIMenuItem*) aRPd7l awjB50:(UIActivity*) awjB50 aOYBhVvb9Lk:(UISwitch*) aOYBhVvb9Lk amk1ipx:(UIEvent*) amk1ipx aSQRA8Gaj:(UISwitch*) aSQRA8Gaj aBQbCuF7S:(UIUserInterfaceIdiom*) aBQbCuF7S { NSLog(@"oJ3tpIi2Wj1CQb07DF9xuesAwUdlVMPy5zS8"); NSLog(@"OviYTZQxeyzGqDrVph9Il"); NSLog(@"1nYwG08UQsBNayrXciMIF6OpWqJSghbP"); NSLog(@"I8hM41KFHt93TRPobl6WU2vQ"); NSLog(@"djN3lFYVhs81yXw"); NSLog(@"XzwGTShbdr"); NSLog(@"BWoXx4yKYEVM83mgF"); NSLog(@"ucnWlD7GyX32m9fJq86HiMZ"); NSLog(@"OSUng9Y3h56xBcKET4fblWFVQzCIL87Po"); NSLog(@"l7ngiKRzoGFIDCJOm1S4"); NSLog(@"3OiISGNJWb"); NSLog(@"veuyS94o3WNat7Oj8"); NSLog(@"CXcKYxJPVkiN87ADH6bn"); NSLog(@"YUZVKspW0jNO"); } -(void)a1OIN8Ef:(UIEdgeInsets*) a1OIN8Ef aHvjR:(UIControl*) aHvjR aCInkAH:(UIUserInterfaceIdiom*) aCInkAH autEDqQW:(UIViewController*) autEDqQW a6FtV7BgZ:(UILabel*) a6FtV7BgZ { NSLog(@"uvYCaFHhIi24"); NSLog(@"HOjeIQSVACio9BR3JgUtGMy7ul2YLb6WxrP1ND"); NSLog(@"QXyqEzZYw4WSGKugjAmC"); NSLog(@"SBMhGgTdCrFED5eoONQJUKIaWsb6Alv10nmu3"); NSLog(@"pWIM7OZ21dwB8s"); NSLog(@"wmHTsphKgj8"); NSLog(@"hIAg4NqRvG6CaMbywkQDUBY1zfc5Xm7Hrl8"); NSLog(@"DIre4W9C8ZS2Ymsvqwxt"); NSLog(@"UhYWuA0HOE2Ds"); NSLog(@"wjYdUiTLRG"); NSLog(@"7OpxloznML6BUHJuYvWSich8QKwR"); NSLog(@"A5yzkKbfgW82Bj0pmNsuDtnhx"); NSLog(@"vwBGDuxoJsYZiqF8cem9zC"); NSLog(@"hxjKZkG7w34Xbc1evOT60gYsE5uaIdS"); NSLog(@"GR4BvQYxaIKD801rtdniXg"); NSLog(@"lKYrH4Dh9JmUQRFVspNx6dyS1ktWn"); NSLog(@"1jn0ZKs7Brkl43OxCwALp8VDTbUJEazyQqhiHfF"); NSLog(@"6AOSpyD4Clcj9"); NSLog(@"zXkx9mIfwLrt7Ml"); } @end