SwiftyRecordButtons
Light-wieght flashy Record button that can be easily added to any project
Features
- Burst animation upon click completion
- Detection of click cancel for both states
- Play button
- Rewind & Forward buttons
Requirements
- iOS 11.0+
- Xcode 10
Installation
CocoaPods
You can use CocoaPods to install SwiftyRecordButtons
by adding it to your Podfile
:
use_frameworks!
pod 'SwiftyRecordButtons'
To get the full benefits import SwiftyRecordButtons
wherever you import UIKit
import UIKit
import SwiftyRecordButtons
Manually
- Clone this repo and drop
SwiftyRecordButton.swift
in your project. - Make sure
Copy items if needed
is checked cmd + B
to compile your project and make other swift files have access toSwiftyRecordButton.swift
let button = RecordButton()
in your desired .swift file- Congratulations!
Usage example
Adding the button to the project
import SwiftyRecordButtons
class YourViewController : UIViewController{
let button = RecordButton()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(button)
}
}
RecordButton modfiable properties
open var radius : CGFloat = 100 // Button Radius defaults to CGFloat 100
open var isRecording : Bool = false // Button state will default to not recording
open var iconViewColor : UIColor = UIColor(white: 0.9, alpha: 1) // Color of the inside icon defaults to offwhite color
open var isOnImage = UIImage(named: "stop") // Represents the image bursting away from the button when state switches to isRecording = true
open var isOnColor : UIColor = .red // Button color when isRecording = true - defaults to red color
open var isOnRange : Range<Float> = Range<Float>(uncheckedBounds: (lower: 30, upper: 80)) // The amount of images bursting away from the button for isRecording = true
open var isOffImage = UIImage(named: "record") // Represents the image bursting away from the button when state switches to off
open var isOffColor : UIColor = .gray // Button color when isRecording = false - defaults to gray color
open var isOffRange: Range<Float> = Range<Float>(uncheckedBounds: (lower: 3, upper: 8)) // The amount of images bursting away from the button for isRecording = false
Example with modified properties
import SwiftyRecordButton
class YourViewController:UIViewController{
let button = RecordButton()
override func viewDidLoad(){
super.viewDidLoad()
view.addSubview(button)
// Move the button to the center of the view
button.translatesAutoresizingMaskIntoConstraints = false
button.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
// Modify the button properties
button.radius = 150
button.isOnColor = .green
button.isOffColor = .brow
button.isOnRange = Range<Float>(uncheckedBounds: (lower: 5, upper: 40))
button.isOffRange = Range<Float>(uncheckedBounds: (lower: 1, upper: 10))
}
}
Contribute
We would love you for the contribution to SwiftyRecordButtons, check the LICENSE
file for more info.
Meta
Muhannad Alnemer – @MhndMousa
Distributed under the MIT license. See LICENSE for more information.