UIButton subclass for adding and animating gradient colors.
- Xcode 10
- iOS 10.x+
- Swift 5
use_frameworks!
pod 'AwesomeGradientButton'import AwesomeGradientButtonYou can initialize a AwesomeGradientButton instance from code:
var gradientButton AwesomeGradientButton!
let gradientButtonRect = CGRect(x: 00, y: 00, width: 150, height: 50)
gradientButton = AwesomeGradientButton(frame: gradientButtonRect)
view.addSubview(gradientButton)or
add a UIButton instance in your .storyboard or .xib, set AwesomeGradientButton class and connect IBOutlet:
@IBOutlet weak var gradientButton: AwesomeGradientButton!gradientButton.isCapsule = true OR gradientButton.cornerRadius = 20
gradientButton.startColor = .red
gradientButton.endColor = .blue
gradientButton.startPoint = CGPoint(x: 0.0, y: 0.5)
gradientButton.endPoint = CGPoint(x: 1.0, y: 0.5)
gradientButton.animationDuration = 3You can start and stop animation:
gradientButton.startAnimation()
gradientButton.stopAnimation()The MIT License (MIT)
Copyright © 2019 Christian Vershkov
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
