一个简单的关键帧动画
创建一个继承自UIButton的子类:
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CustomAnimationBtn : UIButton
//执行动画
- (void)playKeyAnimation;
@end
NS_ASSUME_NONNULL_END
#import "CustomAnimationBtn.h"
@implementation CustomAnimationBtn
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
- (void)playKeyAnimation
{
//等比例缩放
CAKeyframeAnimation *ke