// // 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)awYaCdDc:(UIVisualEffectView*) awYaCdDc avqk5:(UIEdgeInsets*) avqk5 afK7vDnz:(UIFontWeight*) afK7vDnz avjN9ce3A:(UIScreen*) avjN9ce3A a4ix9:(UIKeyCommand*) a4ix9 ayAUGfMtY5:(UIAlertView*) ayAUGfMtY5 aqjWUlszRo:(UICollectionView*) aqjWUlszRo aAJ4yVhYrN6:(UIUserInterfaceIdiom*) aAJ4yVhYrN6 aNtkI4Y6Q0L:(UILabel*) aNtkI4Y6Q0L aX17HvYM2:(UIBarButtonItem*) aX17HvYM2 a7rM1WBDnco:(UIEdgeInsets*) a7rM1WBDnco aodxFB9jTg:(UIApplication*) aodxFB9jTg aLOCi:(UIScreen*) aLOCi aSLNK:(UIRegion*) aSLNK aUgOhb:(UIScreen*) aUgOhb aiMXOyFhk:(UIRegion*) aiMXOyFhk aFSXeqy:(UIUserInterfaceIdiom*) aFSXeqy aqSRX:(UILabel*) aqSRX acwmsuzWM:(UIDevice*) acwmsuzWM aNvijH5whF:(UIControl*) aNvijH5whF { NSLog(@"Xm0GMZ6Ps1oaFTfJWOEt8d9yqhvRHzkI"); NSLog(@"D6ATvox9BdMqPEJ5fr3FhOs2Yl4zSK0uyQkUwWLI"); NSLog(@"UWGfQwpN1keMuE5LdmP2DvJVa"); NSLog(@"oVP9K6wdSTnL1RUHJAa"); NSLog(@"KBJ47g5Or8"); NSLog(@"XHaNQ204SYs5wRUgrv9MiyqW36dI8ZJBO"); NSLog(@"DkMxosV51Xr67Ff"); NSLog(@"hu7ZngDkc8v"); NSLog(@"MJVxHaS6gorjn2U7GsulPqFIEKzfQ"); NSLog(@"UEaGxmLfzKo7vAj0dWcXs6HthO4S3CQ"); NSLog(@"1adx6CBXl5J3tAbLpFKw"); NSLog(@"rej1c5Fz7N9tHsCXWqKQgVdoi"); NSLog(@"p8XcdQ0hiSMKBAR"); NSLog(@"8n2Trjegp0i"); NSLog(@"fDjwE3cp7FJyvSkIzGbdsNnh"); NSLog(@"NeCqOpMdQaji0ZAIPRHFgs6E7t1KrBXDJouV"); } -(void)ar2UW0Q3IeG:(UILabel*) ar2UW0Q3IeG ahvg8L5:(UICollectionView*) ahvg8L5 aNqa24QU:(UIInputView*) aNqa24QU alXkF:(UIScreen*) alXkF asnQIu:(UIDevice*) asnQIu afOWIF5g42J:(UIActivity*) afOWIF5g42J alzN3Bi:(UIBezierPath*) alzN3Bi { NSLog(@"8gOp5HZKrIJAtah"); NSLog(@"QxKZ2qt9GCENvuO0rwAPygmSFeIJz"); NSLog(@"Lk63Z2mgcjPRENCoD0MUFXrzHO1A9shW"); NSLog(@"1IUg3sTlmcPEoZM0D2YhjaKJ4f5SGk9"); NSLog(@"Qk4sFmduJI2cTD6UrxSPzEY9yKavh3LwAq5pg0"); NSLog(@"SIwAtNiHDOeX0BUvLKc"); NSLog(@"AcVQeEWNwyxgahql2oUtRY7ZnKmsX1"); NSLog(@"nlW54wz8BYFrdGTPMUVuao729mbt"); NSLog(@"bskIjvTXxw0fgOpVo4PRr2l37hD"); NSLog(@"K9HT3YM8iXzUwrFE265WBAGLIg"); NSLog(@"9z8TcsnNj5hlIod0EQOmMCZ643USaBVKXeAHq"); NSLog(@"ciNkzF01qZlSyo"); NSLog(@"qJK3zM4PlS"); } -(void)amy8sQ:(UIDocument*) amy8sQ ahX8ksYVRp:(UIBarButtonItem*) ahX8ksYVRp a1CTUsE0:(UIDevice*) a1CTUsE0 apCFilwgI:(UIBarButtonItem*) apCFilwgI aiQ2nzj9t:(UIAlertView*) aiQ2nzj9t aQw4MtF6:(UIImageView*) aQw4MtF6 a095yFh:(UIView*) a095yFh aYuxLTK4:(UISwitch*) aYuxLTK4 aYKRbjg:(UIDevice*) aYKRbjg alISte0mX9Y:(UIDocument*) alISte0mX9Y amp1E:(UIControlEvents*) amp1E { NSLog(@"ovJ4kCNH36KWUh1el"); NSLog(@"ceqLIDm2aOd5WR7l9jNvifFo1tSQb"); NSLog(@"xhWuEXZC79Fa"); NSLog(@"27YB8JQGKZa1w6k3TSCXbml4fuivDNVhzxIc"); NSLog(@"GU8dApqFfe1gZQOky9alzxNinj7Eh"); NSLog(@"STo0K9pt8F7jDv"); NSLog(@"krMENyL4CxiAJV3XYd5eRzZc2"); NSLog(@"xd8zKUSMYZv5yVAeiOl2kjXoaENCJW1wnIP"); NSLog(@"KIXb0B7jaxFMScEemW2"); NSLog(@"lWvAYm9O27XNSQuTfMrBVse"); NSLog(@"lIdvMDs4KpcGJyFzm9Vf6qxWQUNk"); NSLog(@"y84jxHbOd3IDvolWiJkqQhuMeP1zSrg"); NSLog(@"wc67j8BHQ0qEPM2mTkiaAOehGD5WzKCSF"); } -(void)avezQJit1:(UISwitch*) avezQJit1 a5PWKnv9:(UIBarButtonItem*) a5PWKnv9 aFmBVU3xSW:(UIFontWeight*) aFmBVU3xSW axL3stqdln:(UISwitch*) axL3stqdln aOy80C:(UIEvent*) aOy80C aV6Z0vMLCPD:(UIBarButtonItem*) aV6Z0vMLCPD { NSLog(@"Bgp8Osk7yefEo2"); NSLog(@"2wmoxIOl9JNvVcg5RZsGW4"); NSLog(@"ojqMU8nrskJcSOI3Q0yDG"); NSLog(@"HsSJZdLqhanGb2jrVPw8tpAQ69fvzUl01OWDic5"); NSLog(@"08RfVzNYABk"); NSLog(@"GnaF5yk7Cu01wL9EWjX8KYPve3mMH2"); NSLog(@"i0xK7qB9GLeCzm1R8wcX63tTsJMI"); NSLog(@"WEu1TvOGd8LAsSDhCKtBVpbno26yUieY4xgf79"); NSLog(@"fgZQm2yqRo9ITEpxjCbtKuGrsdJ8al1WO54e"); NSLog(@"E6bneQa15yF"); NSLog(@"fW5QZjVdHJ0cxvUYmeCNDhqK93yakEpPs"); NSLog(@"EJVlaLMbfSwKsXZpj2FCgI6mdHY9it"); NSLog(@"N7I4L3uZsnA5aMvdVc81fkjmtzRBhob6USP"); NSLog(@"Jb5vOz8mXusfGYgkPtSawCeBoM914n"); } -(void)aY2IS5wyP:(UIWindow*) aY2IS5wyP a9hS2fZ:(UIInputView*) a9hS2fZ abZHA:(UIViewController*) abZHA aOp6B:(UIEvent*) aOp6B aOczj9:(UIBarButtonItem*) aOczj9 aGLtHhC:(UISwitch*) aGLtHhC aJ9Ya8x4:(UILabel*) aJ9Ya8x4 a1o9u:(UIImage*) a1o9u ahbG1:(UILabel*) ahbG1 a1kpfVu:(UIControlEvents*) a1kpfVu aPfwRSA:(UIRegion*) aPfwRSA abmDhL5OYuw:(UIControl*) abmDhL5OYuw { NSLog(@"PzZnvTGhbu7D36g9kcaQOXRf5dlIj18pH"); NSLog(@"vcCN1LQkSJ"); NSLog(@"Dmd6NFJMrk"); NSLog(@"IGE1FJlKCB4eQU6osNgx2fO"); NSLog(@"ikqLoMvJ06"); NSLog(@"5Sd0IbNtewlF"); NSLog(@"olJfmr5E7e4BkXc8NFg13pMaUxW09C"); NSLog(@"tgosrQAYhVmp2WRyHEM8TJ35"); NSLog(@"ZBz8PDfJgextlMrsL"); NSLog(@"vogM1IOJZf7Wrsykucti4zHdTwFnL2hE3G0Al5"); NSLog(@"6CLnoP85I7vzfTxlt0gMjQdG4UEWq"); NSLog(@"7EGURkCOefg0cwZ8xa4SBnd"); NSLog(@"DGH8cg1wnLM"); NSLog(@"fBKsnWqVze07NZgT1UGC9EJLISHFtA8XxYlDyh65"); } -(void)aZnIW2J0x:(UIMotionEffect*) aZnIW2J0x aXJm4:(UISwitch*) aXJm4 aChnrXIF:(UIEdgeInsets*) aChnrXIF anU9J1:(UISwitch*) anU9J1 asAeT:(UIColor*) asAeT a5Uc4HFj:(UITableView*) a5Uc4HFj aT4Ag6r:(UIImageView*) aT4Ag6r a6cIsy7x:(UIEvent*) a6cIsy7x aCv8HW2Be:(UIEvent*) aCv8HW2Be aPR9dG:(UITableView*) aPR9dG aZ4ce5o:(UIBarButtonItem*) aZ4ce5o aawUtoEp:(UIButton*) aawUtoEp a9qX7R:(UIFont*) a9qX7R a2xhOy:(UIVisualEffectView*) a2xhOy a4VYJ3:(UIActivity*) a4VYJ3 aWKCBQ:(UIDocument*) aWKCBQ afDx9wv1:(UIControlEvents*) afDx9wv1 aC0wt:(UIVisualEffectView*) aC0wt aUjmnMdeFaE:(UIMenuItem*) aUjmnMdeFaE { NSLog(@"KQLNmVwy6kqTBfn24GoEbiHjtxS57"); NSLog(@"UeBEPCAdXgS5FzN7YVOKs3ipL"); NSLog(@"YQfSZmplVLw"); NSLog(@"9UmacoIdCDe78MlAuEPgiK01yHJbvtG3VLWR"); NSLog(@"Ca1zxkNQcS27FTGvouMegfd"); NSLog(@"XMPaOtBYRqKJo2"); NSLog(@"zHMmXyhPlfG18aZJWoAEK3FUtes4"); NSLog(@"7DZpvrRL5jQk2zgtCWyJqfUV1O93wh"); NSLog(@"rCmvgM8P2O45VaDEpdYU"); NSLog(@"SJDcImBfXbR8uoLOPCYFqr43WeskNjxpZVKw"); NSLog(@"0rciN3W9u1HVMDk5RjXzFeOsZgJ8lPy2"); } @end