IAM試圖創建的UIButton 脈動動畫這些是我的代碼,到目前爲止,但仍是無法做到在這個環節如何爲UIButton iOS創建一個脈動動畫?
我的代碼
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];
好吧加入我的項目 – 2015-04-01 08:01:32
酷它的工作 – 2015-04-01 08:06:11
謝謝。它的工作正常。 – Raja 2017-01-02 09:18:20