长按实现图标抖动和删除的代码例子
2011-07-07 18:05
363 查看
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #518187}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3f2080}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7140a8}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #00830e}
span.s1 {color: #b931a1}
span.s2 {color: #000000}
span.s3 {color: #7140a8}
span.s4 {color: #518187}
span.s5 {color: #77492d}
span.s6 {color: #3130d6}
span.s7 {color: #3f2080}
span.Apple-tab-span {white-space:pre}
- (void)wobble { static BOOL wobblesLeft = NO; if (isShake) { CGFloat rotation = (kWobbleRadians * M_PI) / 180.0; CGAffineTransform wobbleLeft = CGAffineTransformMakeRotation(rotation); CGAffineTransform wobbleRight = CGAffineTransformMakeRotation(-rotation); [UIView beginAnimations:nil context:nil]; NSInteger i = 0; NSInteger nWobblyButtons = 0;// for (NSArray* buttonPage in _buttons) {// for (TTLauncherButton* button in buttonPage) {// if (button != _dragButton) {// ++nWobblyButtons;// if (i % 2) {// button.transform = wobblesLeft ? wobbleRight : wobbleLeft;// // } else {// button.transform = wobblesLeft ? wobbleLeft : wobbleRight;// }// }// ++i;// }// } for (UIView *tempView in [scrollView subviews]) { if ([tempView isKindOfClass:[TestView class]] || [tempView isKindOfClass:[UIButton class]]) { ++nWobblyButtons; if (i % 2) { tempView.transform = wobblesLeft ? wobbleRight : wobbleLeft; } else { tempView.transform = wobblesLeft ? wobbleLeft : wobbleRight; } ++i; } } if (nWobblyButtons >= 1) { [UIView setAnimationDuration:kWobbleTime]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(wobble)]; wobblesLeft = !wobblesLeft; } else { [NSObject cancelPreviousPerformRequestsWithTarget:self]; [self performSelector:@selector(wobble) withObject:nil afterDelay:kWobbleTime]; } [UIView commitAnimations]; }}
- (void)startTimer { isShake = YES; if (shakeViewTimer == nil) { shakeViewTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(wobble) userInfo:nil repeats:NO]; }}
- (void)stopShake { isShake = NO; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3f];// [UIView setAnimationDelegate:self]; for (UIView *tempView in [scrollView subviews]) { tempView.transform = CGAffineTransformIdentity; } [UIView commitAnimations]; for (UIView *tempView in [scrollView subviews]) { if ([tempView isKindOfClass:[UIButton class]]) { [tempView removeFromSuperview]; } }}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #518187}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3f2080}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7140a8}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #00830e}
span.s1 {color: #b931a1}
span.s2 {color: #000000}
span.s3 {color: #7140a8}
span.s4 {color: #518187}
span.s5 {color: #77492d}
span.s6 {color: #3130d6}
span.s7 {color: #3f2080}
span.Apple-tab-span {white-space:pre}
- (void)wobble { static BOOL wobblesLeft = NO; if (isShake) { CGFloat rotation = (kWobbleRadians * M_PI) / 180.0; CGAffineTransform wobbleLeft = CGAffineTransformMakeRotation(rotation); CGAffineTransform wobbleRight = CGAffineTransformMakeRotation(-rotation); [UIView beginAnimations:nil context:nil]; NSInteger i = 0; NSInteger nWobblyButtons = 0;// for (NSArray* buttonPage in _buttons) {// for (TTLauncherButton* button in buttonPage) {// if (button != _dragButton) {// ++nWobblyButtons;// if (i % 2) {// button.transform = wobblesLeft ? wobbleRight : wobbleLeft;// // } else {// button.transform = wobblesLeft ? wobbleLeft : wobbleRight;// }// }// ++i;// }// } for (UIView *tempView in [scrollView subviews]) { if ([tempView isKindOfClass:[TestView class]] || [tempView isKindOfClass:[UIButton class]]) { ++nWobblyButtons; if (i % 2) { tempView.transform = wobblesLeft ? wobbleRight : wobbleLeft; } else { tempView.transform = wobblesLeft ? wobbleLeft : wobbleRight; } ++i; } } if (nWobblyButtons >= 1) { [UIView setAnimationDuration:kWobbleTime]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(wobble)]; wobblesLeft = !wobblesLeft; } else { [NSObject cancelPreviousPerformRequestsWithTarget:self]; [self performSelector:@selector(wobble) withObject:nil afterDelay:kWobbleTime]; } [UIView commitAnimations]; }}
- (void)startTimer { isShake = YES; if (shakeViewTimer == nil) { shakeViewTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(wobble) userInfo:nil repeats:NO]; }}
- (void)stopShake { isShake = NO; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3f];// [UIView setAnimationDelegate:self]; for (UIView *tempView in [scrollView subviews]) { tempView.transform = CGAffineTransformIdentity; } [UIView commitAnimations]; for (UIView *tempView in [scrollView subviews]) { if ([tempView isKindOfClass:[UIButton class]]) { [tempView removeFromSuperview]; } }}
相关文章推荐
- 长按实现图标抖动和删除的代码例子
- 使用UICollectionView实现应用程序管理(删除图标 抖动效果)
- php原始代码实现无刷新删除
- php原始代码实现无刷新删除
- C# ASP.NET 最常用的通用权限的3个方法例子展示(每个功能一行代码实现)
- js删除select中重复项的实现代码
- 简单PHP上传图片、删除图片实现代码
- blockchain 区块链200行代码:在JavaScript实现的一个简单的例子
- vbscript Registry 注册表操作实现代码(读写删除)
- 递归算法及经典递归例子代码实现
- 删除C语言程序中所有的注释语句,代码实现
- JS调用C#后台代码---JS实现DataGrid“全选”、“反选”、调用后台代码批量删除数据
- Vbs脚本实现radmin终极后门代码_删除自身
- Android自定义view系列之99.99%实现QQ侧滑删除效果实例代码详解
- KNN算法例子(java,scala,python 代码实现)
- GridView实现可长按item显示可删除的小图标的UI
- 以较少代码实现DataGrid的排序,翻页,删除等功能【2】
- asp.net gridview实现全选,反选与删除记录的操作代码
- iOS:删除storyBoard,纯代码实现UITabBarController的视图切换功能
- javascript圆盘抽奖程序实现原理和完整代码例子