Skip to content

NDrive/AvePurchaseButton

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AvePurchaseButton

Drop In App Store Styled Purchase Button, with proper animations. Title configurable in Interface Builder.

Animations

A gif-movie showing how the button animates from normal to confirmation to in-progress state: Movie

Screenshot

A screenshot showing the different states of the button: Screenshot

How to use

Create an instance of AvePurchaseButton. Set the normalTitle, confirmationTitle and handle UIControlEventTouchUpInside. To change states, use -[AvePurchaseButton setButtonState:animated:].

Example usage:

- (void)addPurchaseButton {
  AvePurchaseButton* button = [[AvePurchaseButton alloc] initWithFrame:CGRectZero];
	[button addTarget:self action:@selector(purchaseButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
	button.buttonState = AvePurchaseButtonStateNormal;
	button.normalTitle = @"$ 2.99";
	button.confirmationTitle = @"BUY";
	[button sizeToFit];
	[self.view addSubview:button];
}

- (void)purchaseButtonTapped:(AvePurchaseButton*)button {
	switch(button.buttonState) {
		case AvePurchaseButtonStateNormal:
			[button setButtonState:AvePurchaseButtonStateConfirmation animated:YES];
			break;
			
		case AvePurchaseButtonStateConfirmation:
			// start the purchasing progress here, when done, go back to 
			// AvePurchaseButtonStateProgress
			[button setButtonState:AvePurchaseButtonStateProgress animated:YES];
			
			[self startPurchaseWithCompletionHandler:^{
			   [button setButtonState:AvePurchaseButtonStateNormal animated:YES];
			}];
			break;
			
		case AvePurchaseButtonStateProgress:
			break;
	}
}

About

iOS App Store Styled Purchase Button

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 97.2%
  • Ruby 2.8%