Skip to content

marcoscurvello/MCActivityButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCActivityButton

CI Status Version license MIT

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.

Demo

Requirements

  • ARC

Installation

CocoaPods

Podfile

pod "MCActivityButton"

Usage

#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];

To-do's

  • 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.

Author

Marcos Curvello, mrcurvello@gmail.com

License

MCActivityButton is available under the MIT License. See the LICENSE file for more info.

About

UIButton that animates a custom message with an activity indicator.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published