【发布时间】:2015-06-12 08:36:54
【问题描述】:
我正在尝试摇晃UIAlertView。我已经制作了alertView 以保持按钮单击,但摇动动画不起作用。这是我所拥有的:
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
self.direction = 1;
self.shakes = 0;
[self shake:aUIView];
}
}
-(void)shake:(UIAlertView *)theOneYouWannaShake
{
[UIView animateWithDuration:0.03 animations:^ {
theOneYouWannaShake.transform = CGAffineTransformMakeTranslation(5 * self.direction, 0);
}
completion:^(BOOL finished) {
if(self.shakes >= 10) {
theOneYouWannaShake.transform = CGAffineTransformIdentity;
return;
}
self.shakes++;
self.direction = self.direction * -1;
[self shake:theOneYouWannaShake];
}];
}
我尝试将NSLog 放入- (void)shake... 并得到输出。所以我的代码一定有问题,为什么alertView 没有晃动。
【问题讨论】:
-
再一次,你必须继承你的 UIView/AlertView 或者使用这个 github.com/lukestringer90/ShakingAlertView 库
-
@user3693546 我试过了,但是没用
-
你是指整个屏幕抖动还是只是 AlertView?
-
只是
alertView -
@Jessica 查看答案 Jessy。
标签: ios objective-c animation uialertview