UIButton,但更具弹性和能够使用您自己的图标和属性文本。
以下是她行动中的视频,您可以在这里找到!链接
将文件 CINBouncyButton.{h,m}
复制到您的项目中。
导入头文件,实例化一个 CINBouncyButton
实例,将其添加为子视图,并惊叹于它的效果。
#import "CINBouncyButton.h"
@implementation XYZ
- (void)viewDidLoad {
UIImage *buttonImage = [UIImage imageNamed:@"icon_twitter"];
NSAttributedString *buttonTitle = [[NSAttributedString alloc] initWithString:@"Connect on Twitter!" attributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
CINBouncyButton *twitterButton = [[CINBouncyButton alloc] initWithFrame:CGRectMake(40.0f, 40.0f, 250.0f, 40.0f) image:buttonImage andTitle:buttonTitle];
[twitterButton setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:twitterButton];
[super viewDidLoad];
}
@end
在尝试构建和运行项目之前,请确保运行 pod install
粘土动图(请观看视频而非动画!)