1.设置View顺时针旋转
//音乐播放旋转
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
//默认是顺时针效果,若将fromValue和toValue的值互换,则为逆时针效果
animation.fromValue = [NSNumber numberWithFloat:0.f];
animation.toValue = [NSNumber numberWithFloat: M_PI *2];
animation.duration = 5;//旋转时间5s一轮
animation.autoreverses = NO;
animation.fillMode =kCAFillModeForwards;
animation.repeatCount = MAXFLOAT; //如果这里想设置成一直自旋转,可以设置为MAXFLOAT,否则设置具体的数值则代表执行多少次
[bottomView.layer addAnimation:animation forKey:nil];
2.点击button放大再缩小的功能
-(void)rightButtonClick:(UIButton*)sender{
sender.transform = CGAffineTransformIdentity;
[UIView animateKeyframesWithDuration:0.5 delay:0 options:0 animations: ^{
[UIView addKeyframeWithRelativeStartTime:0 relativeDuration:1 / 3.0 animations: ^{
sender.transform = CGAffineTransformMakeScale(1.5, 1.5);
}];
[UIView addKeyframeWithRelativeStartTime:1/3.0 relativeDuration:1/3.0 animations: ^{
sender.transform = CGAffineTransformMakeScale(0.8, 0.8);
}];
[UIView addKeyframeWithRelativeStartTime:2/3.0 relativeDuration:1/3.0 animations: ^{
sender.transform = CGAffineTransformMakeScale(1.0, 1.0);
}];
} completion:nil];
}
3.
网友评论