一个具有类似 Twitter 按钮的美丽选中动画的生动按钮。
支持使用 UIButton setImage:forState:自定义图像形状。
TTAnimationButton 可在 CocoaPods 上获取。只需将其添加到您的项目 Podfile 中即可
pod 'TTAnimationButton'
如同 UIButton 一样使用
TTAnimationButton *button = [TTAnimationButton buttonWithType:UIButtonTypeCustom];
button.explosionRate = 100;
[button setImage:[UIImage imageNamed:@"heart"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[button sizeToFit];
/**
* Set button selected image color, default red.
*/
@property (nonatomic, strong) UIColor *imageSelectedColor;
/**
* Set button normal image color, default lightGray.
*/
@property (nonatomic, strong) UIColor *imageNormalColor;
/**
* Explosion density, higher leads more particles, default 0 with no explosion.
*/
@property (nonatomic, assign) NSInteger explosionRate;
/**
* YES to allow customize image size, set before setting image, default NO.
*/
@property (nonatomic, assign) BOOL enableCustomImageSize;
/**
* YES to disable the animation, default NO.
*/
@property (nonatomic, assign) BOOL disableAnimation;