https://github.com/PGSSoft/InAppPurchaseButton
InAppPurchaseButtonA simple and customisable in-app purchase button, written in Swift.
一个简单和可定制的应用内购买按钮,论文,开题报告,用Swift编写。
InstallationThe most convenient way to install it is by using Cocoapods with Podfile:
pod 'InAppPurchaseButton'or using Carthage and add a line to Cartfile:
github 'PGSSoft/InAppPurchaseButton'RequirementsiOS 8.4
Usageimport InAppPurchaseButtonAdding controlOpen your storyboard or xib and drag and drop UIButton control.
Change custom class to InAppPurchaseButton.
Add constrains, but bear in mind that InAppPurchaseButton changes intrinsic content size by itself, so adding constrains like height or width will cause unexpected behaviour.
If you want to control size of InAppPurchaseButton, take a look at minExpandedSize and prefferedTitleMargins properties.
InAppPurchaseButton might have following states:
regular (active for purchased item or inactive for not purchased item) - use it to display text like Open (active) or Buy (for inactive)
Example:
button.buttonState = .regular(animate: true, intermediateState: .active)busy - intermediate state between regular and downloading, usually used when application is waiting for something (e.g. response from the server)
Example:
button.buttonState = .busy(animate: true)downloading - showing current progress
Example
button.buttonState = .downloading(progress: 0.25)Configurable properties:minExpandedSize - minimum size for expanded state
prefferedTitleMargins - preferred space between text and edges
borderColorForInactiveState - border color for inactive state
borderColorForActiveState - border color for active state
backgroundColorForInactiveState - fill color of the button in inactive state
backgroundColorForActiveState - fill color of the button in active state
imageForInactiveState - stretchable background image of the button in inactive state
imageForActiveState - stretchable background image of the button in active state
widthForBusyView - diameter of the button in case when indicator view is shown
cornerRadiusForExpandedBorder - corner radius of the border during transition from .regular to .busy state
borderWidthForBusyView - border width for .busy state
borderWidthForProgressView - border width for .downloading state
ringColorForProgressView - color of the ring for .downloading state
attributedTextForProgressView - attributed string for .downloading state
indicatorImageForProgressMode - alternatively it is possible to display image for .downloading state
transitionAnimationDuration - the speed for all transition animations
shouldAlwaysDisplayBorder - indicates whether border for .active or .inactive should be visible all the time or only during transition (false by default)
attributedTextForInactiveState - attributed string for .inactive state
attributedTextForActiveState attributed string for .active state
For more information, please check InAppPurchaseButton.swift documentation and examples