MCActivityButton
is an objective-c UIButton
subclass that animates a standard iOS activity indicator with a custom title when tapped.
This is currently a work in progress and has not been thoroughly tested. Use at your own risk.
- ARC
pod "MCActivityButton"
#import <MCActivityButton/MCActivityButton.h>
Create a MCActivityButton
object and customize it.
MCActivityButton *button = [MCActivityButton alloc] initWithFrame:CGRectMake()];
Once you have your button object customize it like so:
// Default UIButton customization
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
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.lockTaps = 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];
- Fully implement view tests.
- Dynamic frame calculations.
- Different animation styles.
- Different activity indicator styles.
- Background and title color change.
- Swift version is underway, with all the above mentioned to-do's.
Marcos Curvello, [email protected]
MCActivityButton
is available under the MIT License. See the LICENSE file for more info.