animatableplaybutton

Welcome to the documentation for AnimatablePlayButton. This library allows you to create custom animated play buttons for your iOS applications. It provides a wide range of styling options and animations to enhance the visual appeal of your buttons.

Installation

To install AnimatablePlayButton in your project, you can use CocoaPods. Simply add the following line to your Podfile:

// Podfile

platform :ios, '9.0'

target 'YourTarget' do
    pod 'AnimatablePlayButton'
end

Then run the following command:

$ pod install

Usage

To use AnimatablePlayButton in your project, follow these steps:

  • Import the library in your view controller:
  • Add a UIView to your storyboard or xib file and set its custom class to AnimatablePlayButton.
  • Create an outlet for the AnimatablePlayButton in your view controller:
  • Customize the button’s appearance and animations using the provided properties and methods. Refer to the Properties and Methods sections below for more details.
  • Finally, handle the button’s tap action using either Interface Builder or programmatically:

Properties

AnimatablePlayButton provides the following properties for customization:

  • buttonBackgroundColor – The background color of the play button.
  • buttonTintColor – The tint color of the play button icon.
  • buttonCornerRadius – The corner radius of the play button.
  • buttonBorderWidth – The border width of the play button.
  • buttonBorderColor – The border color of the play button.
  • playImage – The image to be used for the play icon. If not set, a default play icon will be used.

Methods

AnimatablePlayButton provides the following methods:

  • setPlaying – Sets the button’s state to “playing” and starts the animation.
  • setStopped – Sets the button’s state to “stopped” and stops the animation.
  • setAnimationDuration – Sets the duration for the button’s animation.
  • setAnimationRepeatCount – Sets the number of times the button’s animation should repeat. Set to INFINITY for infinite repeat.

Examples

Here are a few examples showcasing different ways to customize AnimatablePlayButton:

// Swift
playButton.buttonBackgroundColor = UIColor.red
playButton.setAnimationDuration(2.0)
playButton.setAnimationRepeatCount(5)
playButton.playImage = UIImage(named: "customIcon")

// Objective-C
self.playButton.buttonBackgroundColor = [UIColor redColor];
[self.playButton setAnimationDuration:2.0];
[self.playButton setAnimationRepeatCount:5];
self.playButton.playImage = [UIImage imageNamed:@"customIcon"];