我正在尝试通过在 View 加载后来回更改 alpha 级别来使其中包含图像的 uibutton 缓慢脉动...
目前我正在这样做,但它什么也没做......
-(void)loopdyloop
{
while ( myCount < 1000 )
{
[UIView animateWithDuration:3.0
delay:0.0f
options:UIViewAnimationCurveEaseOut
animations:^{
iconButton.alpha = 0.0;
} completion:^(BOOL finished) {
if (finished) {
NSLog(@"animated");
}
}];
[UIView animateWithDuration:3.0
delay:0.0f
options:UIViewAnimationCurveEaseOut
animations:^{
iconButton.alpha = 1.0;
} completion:^(BOOL finished) {
if (finished) {
NSLog(@"animated");
}
}];
myCount++;
}
}
这个方法是从 viewdidload 方法中调用的,
我知道这很粗糙,但这是我最好的尝试,如果您对我如何实现这一目标有任何想法,将不胜感激。
最佳答案
在 viewDidLoad
中的按钮层中应用它怎么样? :
CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
pulseAnimation.duration = .5;
pulseAnimation.toValue = [NSNumber numberWithFloat:1.1];
pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pulseAnimation.autoreverses = YES;
pulseAnimation.repeatCount = FLT_MAX;
[YOURButton.layer addAnimation:pulseAnimation forKey:nil];
你可以尝试一下。
关于iphone - 让 uibutton 跳动。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11445298/