Mad*_*vad 3 animation objective-c ios ios5 ios6
我一直试图找到这个底部,它逃脱了我.当用户按下它时,我想要一些按钮.但我不想隐藏它们,而是想要一个动画.我让它们变大,然后缩小到针头,同时也逐渐淡出.
我实际上在iOS6中有这个工作,但我想我会在iOS5.1的模拟器和我的iPad1上运行它.这两个都使按钮动画错误.它在增长,但似乎在屏幕上爆炸成另一个维度.
#pragma mark - animations
-(void)grow:(UIButton *)button {
void (^makeItGrow)(void)= ^{
button.transform = CGAffineTransformScale(button.transform,1.6, 1.6);
};
void (^whenFinished)(BOOL) =
^(BOOL finished) {
if (finished) {
[self shrink:button];
}
};
[UIView animateWithDuration:1 animations:makeItGrow completion:whenFinished];
}
-(void)shrink:(UIButton *)button {
void (^makeItShrink)(void)= ^{
button.transform = CGAffineTransformScale(button.transform, 0.0, 0.0);
button.alpha = 0.0;
};
void (^whenFinished)(BOOL) =
^(BOOL finished) {
if (finished) {
//NSLog(@"shrink finished");
[button setHidden:YES];
[self resetButton:button];
}
};
[UIView animateWithDuration:3 animations:makeItShrink completion:whenFinished];
}
Run Code Online (Sandbox Code Playgroud)
我放慢了动画的速度,所以我可以看得更清楚.第一部分应该如此,但第二部分(收缩)要么碎片进入屏幕(你必须看到它,看起来确实很酷),或者它只是继续在屏幕外生长!当然不是你想要的.
是的,我还在学习,我可能会对我的编码风格有所了解:-)
尝试设置非常低但不等于零的比例因子.
button.transform = CGAffineTransformScale(button.transform, 0.0001, 0.0001);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
380 次 |
| 最近记录: |