Leonif
4/6/2019 - 1:26 PM

Grdient Button

Now you can adв gradient on button, which is updated with buttonautolayout


// MARK: - custom class 
class GradientButton: UIButton {
  override class var layerClass: Swift.AnyClass {
    return CAGradientLayer.self
  }
}


// MARK: - usage example of Gradient Button
guard let gradientLayer = button.layer as? CAGradientLayer else { return }
gradientLayer.colors = [UIColor.tangerine.cgColor, UIColor.marigold.cgColor]
gradientLayer.startPoint = CGPoint(x: 0, y: 0.5)
gradientLayer.endPoint = CGPoint(x: 1, y: 0.5)