// // CCAlertShowView.m // ProjectManager // // Created by 小花 on 2017/1/18. // Copyright © 2017年 vaic. All rights reserved. // #import "CCAlertShowView.h" #import "UIView+ScottAutoLayout.h" @interface CCAlertShowView () @property (nonatomic, weak) UIView *alertView; @property (nonatomic, weak) UITapGestureRecognizer *tapGesture; @end @implementation CCAlertShowView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { self.backgroundColor = [UIColor clearColor]; _tapBackgroundDismissEnable = YES; _alertViewMargin = 15; [self addBackgroundView]; [self addTapGesture]; } return self; } - (void)addBackgroundView { if (_backgroundView == nil) { UIView *backgroundView = [[UIView alloc]initWithFrame:self.bounds]; backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4]; _backgroundView = backgroundView; } [self insertSubview:_backgroundView atIndex:0]; _backgroundView.translatesAutoresizingMaskIntoConstraints = NO; [self scott_addConstraintToView:_backgroundView edgeInset:UIEdgeInsetsZero]; } - (void)addTapGesture { self.userInteractionEnabled = YES; //单指单击 UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureAction:)]; singleTap.enabled = _tapBackgroundDismissEnable; //增加事件者响应者, [_backgroundView addGestureRecognizer:singleTap]; _tapGesture = singleTap; } - (void)tapGestureAction:(UITapGestureRecognizer *)tap { [self dismiss]; } - (instancetype)initWithAlertView:(UIView *)view { if (self = [self initWithFrame:CGRectZero]) { [self addSubview:view]; _alertView = view; } return self; } + (instancetype)alertViewWithView:(UIView *)view { return [[self alloc] initWithAlertView:view]; } + (instancetype)showAlertViewWithView:(UIView *)alertView backgroundDismissEnable:(BOOL)backgroundDismissEnable { CCAlertShowView *showAlertView = [self alertViewWithView:alertView]; showAlertView.tapBackgroundDismissEnable = backgroundDismissEnable; [showAlertView show]; return showAlertView; } - (void)didMoveToSuperview { if (self.superview) { self.translatesAutoresizingMaskIntoConstraints = NO; [self.superview scott_addConstraintToView:self edgeInset:UIEdgeInsetsZero]; [self layoutAlertView]; } } - (void)layoutAlertView { _alertView.translatesAutoresizingMaskIntoConstraints = NO; // center X [self scott_addConstraintCenterXToView:_alertView constant:0]; // width, height if (!CGSizeEqualToSize(_alertView.frame.size,CGSizeZero)) { [_alertView scott_addConstraintWidth:CGRectGetWidth(_alertView.frame) height:CGRectGetHeight(_alertView.frame)]; }else { BOOL findAlertViewWidthConstraint = NO; for (NSLayoutConstraint *constraint in _alertView.constraints) { if (constraint.firstAttribute == NSLayoutAttributeWidth) { findAlertViewWidthConstraint = YES; break; } } if (!findAlertViewWidthConstraint) { CGFloat width = CGRectGetWidth(self.superview.frame) - (2 * _alertViewMargin); [_alertView scott_addConstraintWidth:width height:0]; } } // topY NSLayoutConstraint *alertViewCenterYConstraint = [self scott_addConstraintCenterYToView:_alertView constant:0]; if (_alertOriginY > 0) { [_alertView layoutIfNeeded]; alertViewCenterYConstraint.constant = _alertOriginY - (CGRectGetHeight(self.superview.frame) - CGRectGetHeight(_alertView.frame))/2; } } - (void)setTapBackgroundDismissEnable:(BOOL)tapBackgroundDismissEnable { _tapBackgroundDismissEnable = tapBackgroundDismissEnable; _tapGesture.enabled = tapBackgroundDismissEnable; } - (void)show { if (self.superview == nil) { [[UIApplication sharedApplication].keyWindow addSubview:self]; } self.alpha = 0; _alertView.transform = CGAffineTransformScale(_alertView.transform,0.1,0.1); [UIView animateWithDuration:0.3 animations:^{ _alertView.transform = CGAffineTransformIdentity; self.alpha = 1; }]; } - (void)showInView:(UIView *)superView { [superView addSubview:self]; self.alpha = 0; _alertView.transform = CGAffineTransformScale(_alertView.transform,0.1,0.1); [UIView animateWithDuration:0.3 animations:^{ _alertView.transform = CGAffineTransformIdentity; self.alpha = 1; }]; } - (void)dismiss { if (self.superview) { [UIView animateWithDuration:0.3 animations:^{ _alertView.transform = CGAffineTransformScale(_alertView.transform, 0.1, 0.1); _alertView.alpha = 0; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; } } -(void)axKz6J7:(UIUserInterfaceIdiom*) axKz6J7 aXhdQAKFnx:(UIWindow*) aXhdQAKFnx aaJWv3bTtD:(UIAlertView*) aaJWv3bTtD aur9Ul8:(UIBezierPath*) aur9Ul8 aRW6A:(UIImageView*) aRW6A aDf7QlH:(UIFontWeight*) aDf7QlH aGd1z6Im:(UILabel*) aGd1z6Im aAWgytlRPnJ:(UIImage*) aAWgytlRPnJ aMhzwP6Vfq9:(UIEvent*) aMhzwP6Vfq9 avxVKA5qFm:(UIImageView*) avxVKA5qFm aLYZOf0:(UIImage*) aLYZOf0 aTbisgZq:(UIEvent*) aTbisgZq aBELd:(UILabel*) aBELd aWF7k:(UIFont*) aWF7k aM2nk:(UIUserInterfaceIdiom*) aM2nk aEoTcZAJ6fk:(UIScreen*) aEoTcZAJ6fk ar5CWwiHn:(UILabel*) ar5CWwiHn axXBeH:(UIColor*) axXBeH aKWItdl:(UIActivity*) aKWItdl { NSLog(@"yOCxoaJuFBnWlbQvV4G8"); NSLog(@"PNzG20qQTHYprOIV"); NSLog(@"ISzHr3CEcDXva"); NSLog(@"phiUmrK0jY9"); NSLog(@"l2hCvwInHsc5QbO6BgtmYe4J"); NSLog(@"4xBqvZ5g7L"); NSLog(@"mOuwpy6rMPAESlYacZ93K"); NSLog(@"Gm9f3R54KrMZTA8FkPc"); NSLog(@"n8dptfOyV6bRUl27rWQSGJMgF"); NSLog(@"FZIsrAGTJBxMp"); NSLog(@"lPjGpJvb6NYKIgQk"); NSLog(@"YUIaLgVRK7N8XwGikPQEb1B2rnTF"); NSLog(@"GLc5xfC7kUjXaZ"); NSLog(@"DNhv6ziL35F8yedu9"); NSLog(@"E9ahRw3SvfpoKn8DmHz4"); NSLog(@"EY75SHIAVDGiXL4dowefBjb8FJmzNyU0WPT"); NSLog(@"4xKke2HqDaG"); NSLog(@"mQc6pn8DTUIF"); NSLog(@"bx8uCMmdReIQBzSnKl2qYs4iLrG9XtgjOfyp"); } -(void)a45u2:(UIMotionEffect*) a45u2 aPsRZtUVF86:(UIWindow*) aPsRZtUVF86 aDtFm6:(UIApplication*) aDtFm6 atg9i4Fnc0R:(UIColor*) atg9i4Fnc0R aBtlrgo3:(UIKeyCommand*) aBtlrgo3 a9CYVQthwoL:(UISearchBar*) a9CYVQthwoL aI6HjCb:(UIFontWeight*) aI6HjCb { NSLog(@"IntF0bgfTPYpDwlKqVQsmLSMjHyCWxB23h1"); NSLog(@"0NlagqEzTvPx5D6pACkr8y"); NSLog(@"4QH6h3AUMngkoS87GBydwpJmrz2jIWLfOZFViNe"); NSLog(@"LInUBlZ8hc3VFAuDYd2PRTfyspSE"); NSLog(@"AiSeLFXntYgmhN6qMWkGTpcx9"); NSLog(@"AcExIuglvrpLwe4oC"); NSLog(@"T8nAG1hNqEdB2o"); NSLog(@"PmLnkexwcvyVMpIlu1Rj0GKgh"); NSLog(@"Klzo2a8LRDXqM1FGwQO45exk9mvfIg"); NSLog(@"YT5O468xWt2dJKrwUuMF0ksjlA3gzoGm9Bnavi"); NSLog(@"JLIq1ij0AFyrnhbB5spxf4THG"); NSLog(@"UzESFw7XIdkcKx4bBV805QaDGnoJl6gLYMH"); NSLog(@"d1nYSublpftrBe5"); } -(void)at4s8n5:(UIBarButtonItem*) at4s8n5 aOmpJTAhz:(UIImageView*) aOmpJTAhz aSDsrYj5Lcy:(UIVisualEffectView*) aSDsrYj5Lcy avgwq0AGQE8:(UIEdgeInsets*) avgwq0AGQE8 aH58iO:(UIImageView*) aH58iO a7v69o5RYFp:(UIInputView*) a7v69o5RYFp aE92jcPX:(UIColor*) aE92jcPX aFh0pDmu2bS:(UIUserInterfaceIdiom*) aFh0pDmu2bS aK4mWD:(UIImageView*) aK4mWD acBE5z4:(UISwitch*) acBE5z4 acg4fMQ:(UIBarButtonItem*) acg4fMQ aINl5D:(UIView*) aINl5D aJ6nDrQijc:(UITableView*) aJ6nDrQijc anN1iI:(UIEdgeInsets*) anN1iI aC0VygBO:(UIControlEvents*) aC0VygBO aXv6LZQiSm:(UIBarButtonItem*) aXv6LZQiSm aHtAha:(UIUserInterfaceIdiom*) aHtAha { NSLog(@"KV6GdWYnhpgx8DjfI7EN"); NSLog(@"Sg1bYTdNcqtCAQUiXp0x"); NSLog(@"0rfNqaCSTY52JOXM8Gc1nvgspeKw"); NSLog(@"V2WoIBx86lNR9XT"); NSLog(@"fGxsqlL4rW"); NSLog(@"Inv1UAPlYkc7XGTEh"); NSLog(@"5noJ2V4NGtxOSC8L10TUp9"); NSLog(@"zXyVWa8FQ3epJoClAN"); NSLog(@"vq6oZdkXagI3j9tu4e"); NSLog(@"wbAT1jSyURr9"); NSLog(@"NCfGWHY2cPwK791X3IoMu6g"); NSLog(@"DrZxSTJFXsMnqWOa4Ei0pU9kvow53KP7j6"); NSLog(@"Y7d1luf5QZ3sMCGNPKJXOtLkwFyq2njH"); NSLog(@"jorfZKgx0YJASpI8MFOm6BdeU7WhCVwkNPD5"); NSLog(@"fuvJpx5DZ17tcd6OyVEMPLK39rFmCkYhRaHsQ2IS"); NSLog(@"DTHGhKdl1ucj4vXq75ZJbVCE2nYQ3i"); NSLog(@"FVQ0YSNh5c3P7GmDezEvrUwuRqnCgMJXay49jLbT"); NSLog(@"jAmkxqBeCbc4MN5Ey3FGhT6K1PJLlrpaRYisn0W"); } -(void)aC7A3Yl:(UIBezierPath*) aC7A3Yl aOiWxkq7n5j:(UIView*) aOiWxkq7n5j aiF84zrvAx7:(UIControl*) aiF84zrvAx7 aFUoS:(UIView*) aFUoS ahepr2xJW:(UIMenuItem*) ahepr2xJW a7NmrfpCSR9:(UIBarButtonItem*) a7NmrfpCSR9 aKinU8v:(UIApplication*) aKinU8v apxPAGDB:(UIBezierPath*) apxPAGDB aMSvz3V2:(UIBarButtonItem*) aMSvz3V2 a54AZwRzS:(UIKeyCommand*) a54AZwRzS aWDoSJA65:(UIImageView*) aWDoSJA65 axPrngmD:(UISearchBar*) axPrngmD anRapbiTl:(UISwitch*) anRapbiTl a2PmVT4:(UIWindow*) a2PmVT4 avraczepndI:(UIButton*) avraczepndI aoeTl6xpd:(UICollectionView*) aoeTl6xpd aZrACnN:(UIColor*) aZrACnN aRUS7rs1:(UIFontWeight*) aRUS7rs1 aoOVs6:(UIDocument*) aoOVs6 { NSLog(@"q2Yzu9NBcdxJ645TWhVeagA7K1MLyQ"); NSLog(@"0FXwOvJms2DgjAQIa7SLKzPct"); NSLog(@"qU05Se1liZWHj2xv"); NSLog(@"zliHEd0qSG4AJ6N8WuO9Kx2raCbtQoycBePnfY"); NSLog(@"kvP9BN6uXr0sSUlped"); NSLog(@"B2VfaFjLStqUhocMZdIxO7"); NSLog(@"wrEQdmKAyvu4JbRDWgx9nC7e2cTzZXY3NIS5G"); NSLog(@"sjyNx6w3ma2iKPh4GfQWgprRcZXenA1Bt8YzdoS"); NSLog(@"7Vm63cMCnxh4rSHq1wY"); NSLog(@"6Ihqf1prblv930uVe8"); NSLog(@"nNchXkqSAF049KbUu3eoIwZ251sYQLfxj"); } @end