长按实现图标抖动和删除的代码例子

<style type="text/css"> 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} </style>

- (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];

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值