Giter Club home page Giter Club logo

inapppurchasebutton's Introduction

pgssoft-logo.png

InAppPurchaseButton

A simple and customisable in-app purchase button, written in Swift.

Swift 5.0 CocoaPods Compatible Carthage Compatible SPM Platform License

InAppPurchaseButton.gif

Installation

The 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"

or Swift Package Manager (SMP)

Requirements

iOS, tvOS 9.0

Usage

import InAppPurchaseButton
Adding control

Open your storyboard or xib and drag and drop UIButton control. Change custom class to InAppPurchaseButton.

Adding constraints

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.

Available states

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)

inactive.png

active.png

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)

busy.png

Example:

button.buttonState = .busy(animate: true)
  • downloading - showing current progress

downloading.png

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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/PGSSoft/InAppPurchaseButton.

License

The project is available as open source under the terms of the MIT License.

About

The project maintained by software development agency PGS Software. See our other open-source projects or contact us to develop your product.

Follow us

Twitter URL
Twitter Follow

inapppurchasebutton's People

Contributors

lukedurrant avatar mmysliwiec avatar tbaranes avatar warpling avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.