title: Custom UIButton subclass
body: <p>I'm trying my own custom UIButton. I subclassed the UIButton class and tried to add some functions this is my code:</p>
  
  <pre><code>import UIKit
  
  
  class CustomButton: UIButton {
  
      override init(frame: CGRect) {
          super.init(frame: frame)
          setup()
          setGradientBackground()
      }
  
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
          fatalError("init(coder:) has not been implemented")
      }
  
      private func setup() {
          layer.cornerRadius = 8
      }
  
      private func setGradientBackground() {
  
          let gradientLayer = CAGradientLayer()
          gradientLayer.frame = bounds
          gradientLayer.colors = [UIColor.yellow.cgColor, UIColor.blue.cgColor]
          gradientLayer.locations = [0.0, 1.0]
          gradientLayer.startPoint = CGPoint(x: 1.0, y: 1.0)
          gradientLayer.endPoint = CGPoint(x: 0.0, y: 0.0)
  
          layer.insertSublayer(gradientLayer, at: 0)
      }
  }
  </code></pre>
  
  <p>I linked it to my IBOutlet :</p>
  
  <pre><code>@IBOutlet weak var myButton: CustomButton!
  </code></pre>
  
  <p>And nothing apply !</p>