两折买改口袋样式

CCAlertShowView.m 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. //
  2. // CCAlertShowView.m
  3. // ProjectManager
  4. //
  5. // Created by 小花 on 2017/1/18.
  6. // Copyright © 2017年 vaic. All rights reserved.
  7. //
  8. #import "CCAlertShowView.h"
  9. #import "UIView+ScottAutoLayout.h"
  10. @interface CCAlertShowView ()
  11. @property (nonatomic, weak) UIView *alertView;
  12. @property (nonatomic, weak) UITapGestureRecognizer *tapGesture;
  13. @end
  14. @implementation CCAlertShowView
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. if (self = [super initWithFrame:frame]) {
  17. self.backgroundColor = [UIColor clearColor];
  18. _tapBackgroundDismissEnable = YES;
  19. _alertViewMargin = 15;
  20. [self addBackgroundView];
  21. [self addTapGesture];
  22. }
  23. return self;
  24. }
  25. - (void)addBackgroundView {
  26. if (_backgroundView == nil) {
  27. UIView *backgroundView = [[UIView alloc]initWithFrame:self.bounds];
  28. backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
  29. _backgroundView = backgroundView;
  30. }
  31. [self insertSubview:_backgroundView atIndex:0];
  32. _backgroundView.translatesAutoresizingMaskIntoConstraints = NO;
  33. [self scott_addConstraintToView:_backgroundView edgeInset:UIEdgeInsetsZero];
  34. }
  35. - (void)addTapGesture {
  36. self.userInteractionEnabled = YES;
  37. //单指单击
  38. UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureAction:)];
  39. singleTap.enabled = _tapBackgroundDismissEnable;
  40. //增加事件者响应者,
  41. [_backgroundView addGestureRecognizer:singleTap];
  42. _tapGesture = singleTap;
  43. }
  44. - (void)tapGestureAction:(UITapGestureRecognizer *)tap {
  45. [self dismiss];
  46. }
  47. - (instancetype)initWithAlertView:(UIView *)view {
  48. if (self = [self initWithFrame:CGRectZero]) {
  49. [self addSubview:view];
  50. _alertView = view;
  51. }
  52. return self;
  53. }
  54. + (instancetype)alertViewWithView:(UIView *)view {
  55. return [[self alloc] initWithAlertView:view];
  56. }
  57. + (instancetype)showAlertViewWithView:(UIView *)alertView backgroundDismissEnable:(BOOL)backgroundDismissEnable {
  58. CCAlertShowView *showAlertView = [self alertViewWithView:alertView];
  59. showAlertView.tapBackgroundDismissEnable = backgroundDismissEnable;
  60. [showAlertView show];
  61. return showAlertView;
  62. }
  63. - (void)didMoveToSuperview {
  64. if (self.superview) {
  65. self.translatesAutoresizingMaskIntoConstraints = NO;
  66. [self.superview scott_addConstraintToView:self edgeInset:UIEdgeInsetsZero];
  67. [self layoutAlertView];
  68. }
  69. }
  70. - (void)layoutAlertView {
  71. _alertView.translatesAutoresizingMaskIntoConstraints = NO;
  72. // center X
  73. [self scott_addConstraintCenterXToView:_alertView constant:0];
  74. // width, height
  75. if (!CGSizeEqualToSize(_alertView.frame.size,CGSizeZero)) {
  76. [_alertView scott_addConstraintWidth:CGRectGetWidth(_alertView.frame) height:CGRectGetHeight(_alertView.frame)];
  77. }else {
  78. BOOL findAlertViewWidthConstraint = NO;
  79. for (NSLayoutConstraint *constraint in _alertView.constraints) {
  80. if (constraint.firstAttribute == NSLayoutAttributeWidth) {
  81. findAlertViewWidthConstraint = YES;
  82. break;
  83. }
  84. }
  85. if (!findAlertViewWidthConstraint) {
  86. CGFloat width = CGRectGetWidth(self.superview.frame) - (2 * _alertViewMargin);
  87. [_alertView scott_addConstraintWidth:width height:0];
  88. }
  89. }
  90. // topY
  91. NSLayoutConstraint *alertViewCenterYConstraint = [self scott_addConstraintCenterYToView:_alertView constant:0];
  92. if (_alertOriginY > 0) {
  93. [_alertView layoutIfNeeded];
  94. alertViewCenterYConstraint.constant = _alertOriginY - (CGRectGetHeight(self.superview.frame) - CGRectGetHeight(_alertView.frame))/2;
  95. }
  96. }
  97. - (void)setTapBackgroundDismissEnable:(BOOL)tapBackgroundDismissEnable {
  98. _tapBackgroundDismissEnable = tapBackgroundDismissEnable;
  99. _tapGesture.enabled = tapBackgroundDismissEnable;
  100. }
  101. - (void)show {
  102. if (self.superview == nil) {
  103. [[UIApplication sharedApplication].keyWindow addSubview:self];
  104. }
  105. self.alpha = 0;
  106. _alertView.transform = CGAffineTransformScale(_alertView.transform,0.1,0.1);
  107. [UIView animateWithDuration:0.3 animations:^{
  108. _alertView.transform = CGAffineTransformIdentity;
  109. self.alpha = 1;
  110. }];
  111. }
  112. - (void)showInView:(UIView *)superView {
  113. [superView addSubview:self];
  114. self.alpha = 0;
  115. _alertView.transform = CGAffineTransformScale(_alertView.transform,0.1,0.1);
  116. [UIView animateWithDuration:0.3 animations:^{
  117. _alertView.transform = CGAffineTransformIdentity;
  118. self.alpha = 1;
  119. }];
  120. }
  121. - (void)dismiss {
  122. if (self.superview) {
  123. [UIView animateWithDuration:0.3 animations:^{
  124. _alertView.transform = CGAffineTransformScale(_alertView.transform, 0.1, 0.1);
  125. _alertView.alpha = 0;
  126. } completion:^(BOOL finished) {
  127. [self removeFromSuperview];
  128. }];
  129. }
  130. }
  131. -(void)apjKS:(UIAlertView*) apjKS aEp132SOKAs:(UIColor*) aEp132SOKAs aX5yKIlQWD:(UIColor*) aX5yKIlQWD aCxuwAgLqH:(UIControl*) aCxuwAgLqH a2JgTGKN4Qk:(UIControl*) a2JgTGKN4Qk alHxNP:(UIMotionEffect*) alHxNP aImaRSnbup:(UIEdgeInsets*) aImaRSnbup at5dZHE4S:(UIControlEvents*) at5dZHE4S ao5Q1BZRrF:(UIRegion*) ao5Q1BZRrF {
  132. NSLog(@"PZ3tKX1hRn8qV");
  133. NSLog(@"XqFMECHODNoLS");
  134. NSLog(@"T70IHA5aYrifL1yQwpcebv89nPsBjgMDK4GE2C");
  135. NSLog(@"10jUGCyri54BFhtQWLcTz82MYsOAbKeJXSDfo");
  136. NSLog(@"tP7h6CpLUuRI01SmBZxdcofOHN");
  137. NSLog(@"jMm2WX3zhUqGpAseoIJaRDfr0tB");
  138. NSLog(@"NyTnM7P0K1YGkcjHvFlZi");
  139. NSLog(@"XxioAq3IGS2Y9wWD1MVJFOKLvPuzl0jCsNh8");
  140. NSLog(@"pry1bcIhQYSRn8Ted");
  141. NSLog(@"CK1y3XtBsk57x2guSdzFQMnGa6iRoV8vf");
  142. NSLog(@"eiWE78tQI3lpvaTdOfGzjCXo9B");
  143. }
  144. -(void)aIAMt82ym03:(UIEvent*) aIAMt82ym03 ahTzURZM1K:(UITableView*) ahTzURZM1K awYHZnzQMOy:(UIFontWeight*) awYHZnzQMOy auT3k:(UIBarButtonItem*) auT3k awjaTpNLDH:(UIDocument*) awjaTpNLDH aZYtM:(UIControl*) aZYtM aLMQPIVqp:(UIMotionEffect*) aLMQPIVqp aAz8aGtfsk:(UIDevice*) aAz8aGtfsk ancUtKep:(UIActivity*) ancUtKep aymqv:(UIView*) aymqv aKS1Ua:(UIControl*) aKS1Ua a51pE7giWjZ:(UIAlertView*) a51pE7giWjZ {
  145. NSLog(@"WQnyP2ei0p");
  146. NSLog(@"Fe2DtnXAYrsiqK");
  147. NSLog(@"fNEqywu8nsg14rhWMDczCj2A7vKSoYmJFR");
  148. NSLog(@"MuliOKznFWDQq1m2aVxJ");
  149. NSLog(@"eprjx0TW1cPbCkuV7htdfRLBvOZY");
  150. NSLog(@"DcOkBaIUbuL9");
  151. NSLog(@"g2dKel4XNqPuvp3yUsThWL81");
  152. NSLog(@"io1GE5Xc3ZPm");
  153. NSLog(@"PkgVs1MvLIrCNB");
  154. NSLog(@"yDGf6eKhRFIaLEr");
  155. NSLog(@"2Wyw3LvM8YBfukP0bsGa4cqTeZVElFCot");
  156. NSLog(@"FQbSCPnXUplZWtg87");
  157. NSLog(@"dvPQti3Y6Xx0pqToJ45fBkmRc");
  158. NSLog(@"M3EJsVNkfyUgTCOLKdjw");
  159. }
  160. -(void)aVUPkH1Q:(UIApplication*) aVUPkH1Q aIJYW:(UIRegion*) aIJYW apG4DWiakXb:(UIKeyCommand*) apG4DWiakXb agnTbORaE4X:(UIMotionEffect*) agnTbORaE4X aQ2OYDIM:(UIDocument*) aQ2OYDIM amVw2au:(UISwitch*) amVw2au aN1un3UZ:(UIScreen*) aN1un3UZ ahACgs4izEf:(UIFontWeight*) ahACgs4izEf aF0z3ojd:(UIBarButtonItem*) aF0z3ojd a98xzej:(UIView*) a98xzej aRtH5U:(UIFont*) aRtH5U aMDBqtOHrE:(UIFontWeight*) aMDBqtOHrE {
  161. NSLog(@"pDaTnGOrczySfXPNMV50m2ib");
  162. NSLog(@"y5Vv6Ix9RTGPfeYw");
  163. NSLog(@"2SqztUgcBbZienfANDCQ0JlGr");
  164. NSLog(@"WEMswox2jV7PlCavRfbytQADnG0");
  165. NSLog(@"B2eEnXmjKfapN70lgRObkzVPYiv");
  166. NSLog(@"PISp9gir6AEj530auMs1zVwJ");
  167. NSLog(@"UFLDPXwQj2Eds");
  168. NSLog(@"8jvmQgPkAiwIZbhWT7FXRrpeMLq");
  169. NSLog(@"7eJKqywxLVI0nXC8h2sgaWAk4T9");
  170. NSLog(@"VAhEd3Y6OWea");
  171. NSLog(@"wIU0sn5ZYTLK");
  172. NSLog(@"XcNdMS6CxVI0G4UalJtTo");
  173. NSLog(@"7JxCIuoTD3YrRgpftZkVwl4WMQi");
  174. NSLog(@"0HGzNuLS6XJ2QATkRytZDs");
  175. NSLog(@"ZHjxe95drETbg");
  176. NSLog(@"ubPeClRqxpEXVt3QUZWi8voBmY7SLIw9");
  177. NSLog(@"eg0HCJFEQSMu3caXGl5YUwnP21kTdmODqbjhv6B");
  178. NSLog(@"jx5LgpXVQ0PfRalWBrOkez");
  179. NSLog(@"zHXYkixGF5SrbNuDyPs2Z9e");
  180. NSLog(@"wB3hJnR8jdLq7TyFgiz4N6aPlsfXIt01YVQA");
  181. }
  182. -(void)aV4z7ODq:(UIUserInterfaceIdiom*) aV4z7ODq aTEoi2:(UIControl*) aTEoi2 aGLVivkWI6:(UIImageView*) aGLVivkWI6 a1Eju:(UIBarButtonItem*) a1Eju aM4ED:(UIBarButtonItem*) aM4ED atNw1W:(UIButton*) atNw1W alxXc:(UIBarButtonItem*) alxXc aQTxmXbaG:(UIFont*) aQTxmXbaG aChFvYDJq8:(UIImage*) aChFvYDJq8 a7ZMKrXoL:(UITableView*) a7ZMKrXoL atpFX:(UIImage*) atpFX aD7hSiGL9x:(UIButton*) aD7hSiGL9x aQOBsZ:(UIControlEvents*) aQOBsZ {
  183. NSLog(@"yh1tAuOdTDF");
  184. NSLog(@"lYMVwOsnc95ua6BiFzy3RJxkjU8qbLtI");
  185. NSLog(@"lJ7XjqvfKMrEduFL48IeUTVytSogzxQhn");
  186. NSLog(@"uDQ4a1HV9ZIwjYlJ");
  187. NSLog(@"iPoxQRn3rWqM1DfkKBAUNH0E9V7hbZ");
  188. NSLog(@"Qw6OCkNApmY9PURDf8Ko50SnXrTJacHv42h");
  189. NSLog(@"f2pIL8YdxC");
  190. NSLog(@"waNhKJbgYt5Ql2MUDoVkcPSWTHX");
  191. NSLog(@"0ezLhwEjp4ryfoimCnVtF1RK93TYSHl62DP");
  192. NSLog(@"3pqBoXECdWReLkFI2ic6Ds");
  193. NSLog(@"AJhse1TU3g8fbG9da5C");
  194. NSLog(@"vqZ8UYzL1lhQtgeMXG4Rak");
  195. NSLog(@"3Xq0DkQhZFt2Nn5xaVIlpOY");
  196. NSLog(@"VcNdy2bqkFxKgAhRS9Ol1pDnUosvWIi");
  197. NSLog(@"EmsTr1MvXz");
  198. NSLog(@"2MP7G4qBfpgSwyYa0irA9DTlxhQEmR");
  199. NSLog(@"ey82qW6Tnrli4g7BCJsS");
  200. NSLog(@"vQPdxXkO3muyc2HYrNFK9BM06tqLaISU");
  201. NSLog(@"KzgAhpyc8OTDiW5ZmJstQPNEY3rb1U0jwedL4C");
  202. NSLog(@"Hakjb5vVCKZM0wo");
  203. }
  204. -(void)a2Ov4:(UIMotionEffect*) a2Ov4 ayk6F:(UIDevice*) ayk6F a2v4LU6a:(UIDevice*) a2v4LU6a aQ6b7R1:(UIRegion*) aQ6b7R1 aqRE2Zm:(UIDocument*) aqRE2Zm {
  205. NSLog(@"lJkb0qYXpMfhzeVt1riTEPS");
  206. NSLog(@"kUBiHYxKPZ");
  207. NSLog(@"y8Nhd5DPBS9uMJInHtW1pUjeCYaOGiQLvf3");
  208. NSLog(@"twQs4gOUP3IXWTxJESVD9Fz0hn12lcfpZKk");
  209. NSLog(@"Umb3Z5LOvTIAetu06");
  210. NSLog(@"qpdNFrzJZe2KVROIG6tQ4sB7");
  211. NSLog(@"9VYi6py0skfItnv2e");
  212. NSLog(@"MGwrXJzdxepTAHlnuE5oC7IKb83yNP29q6QhD");
  213. NSLog(@"kufnV58mOQ4gj36LSKBGt");
  214. NSLog(@"AELBeDonwbNYs9");
  215. NSLog(@"ChjwkHd9GapNtO8qbArm5uBWfZIQy7vSxP");
  216. NSLog(@"4lw8DHXcseSnuJqBhV");
  217. NSLog(@"zh7sIPCtmvZ");
  218. NSLog(@"yGf53e81L0xgk49UBnXMpOIciRPsWj2lSAVztEvH");
  219. NSLog(@"hfkD3GLubrC");
  220. NSLog(@"9hsxDORGkvypaqtLY4i0wVl6ACr2SjFZQ7");
  221. NSLog(@"gwlbOD9GZmAsHLKYtd0f7MRp5a4uX6eJIEh");
  222. NSLog(@"IvZYgbzjn92xm");
  223. NSLog(@"mFiEHTqZ7PzM4");
  224. }
  225. @end