小编abh*_*ore的帖子

如何为UIButton iOS创建脉动动画?

我试图为UIButton创建一个脉动动画这些是我的代码到目前为止,但仍然无法做到这个链接中显示的确切动画

CSS脉动按钮

我的代码

 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.backgroundColor = [UIColor lightGrayColor];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
       [button addTarget:self
               action:@selector(method)
     forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@"Show View" forState:UIControlStateNormal];
    button.frame = CGRectMake(80.0, 210.0, 160.0, 160.0);
    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;
    [button.layer addAnimation:pulseAnimation forKey:nil];
    button.layer.cornerRadius=button.frame.size.width / 2;
    ;
    button.layer.masksToBounds = YES;

    [self.view addSubview:button];
Run Code Online (Sandbox Code Playgroud)

animation objective-c uibutton ios

2
推荐指数
1
解决办法
3018
查看次数

标签 统计

animation ×1

ios ×1

objective-c ×1

uibutton ×1