Skip to content

Instantly share code, notes, and snippets.

@litoarias
Created February 20, 2017 13:05
Show Gist options
  • Save litoarias/896a503287aa66eba37ebde57eb8a45f to your computer and use it in GitHub Desktop.
Save litoarias/896a503287aa66eba37ebde57eb8a45f to your computer and use it in GitHub Desktop.
UIButton deasignable cornerRadius, borderWidth, borderColor for Swift 3
import UIKit
@IBDesignable public class HAButton: UIButton {
@IBInspectable var borderColor: UIColor = UIColor.white {
didSet {
layer.borderColor = borderColor.cgColor
setTitleColor(borderColor, for: .normal)
}
}
@IBInspectable var radius: CGFloat = 0.0 {
didSet {
layer.cornerRadius = radius
}
}
@IBInspectable var borderWidth: CGFloat = 0.0 {
didSet {
layer.borderWidth = borderWidth
}
}
override public func layoutSubviews() {
super.layoutSubviews()
clipsToBounds = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment