MCActivityButton
是 Objective-C 中 UIButton
子类的扩展,当点击时将动画化的标准 iOS 活动指示器与自定义标题结合。
目前这还处于开发阶段且未经充分测试。使用时请自行承担风险。
来自 CocoaPods
pod "MCActivityButton"
#import <MCActivityButton/MCActivityButton.h>
创建一个 MCActivityButton
对象并自定义它。
MCActivityButton *button = [MCActivityButton alloc] initWithFrame:CGRectMake()];
一旦您拥有了按钮对象,您可以像这样进行自定义
// Default UIButton customization
button.titleLabel.textColor = [UIColor whiteColor];
button.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:14];
button.backgroundColor = [UIColor colorWithRed:0.000 green:0.294 blue:0.624 alpha:1.000];
// Initial and Action Button Title
button.initialTitle = @"Login";
button.activityTitle = @"Logging in...";
// Locks Subsequent Button Clicks
button.buttonClickLock = YES;
// Button title animation duration
button.buttonAnimationDuration = 0.5;
// Optional Rounded Edges
button.layer.cornerRadius = 5;
button.clipsToBounds = YES;
// Customize Activity Indicator
button.activityIndicatorColor = [UIColor whiteColor];
button.activityIndicatorMargin = 6;
button.activityIndicatorScale = 0.8;
// Then Add Your Button to the view
[self.view addSubview:button];
// Force button to return to it's initial state
[button stopAnimating];
Marcos Curvello,[email protected]