Skip to content

Instantly share code, notes, and snippets.

@shishirthedev
Created January 20, 2019 05:16
Show Gist options
  • Select an option

  • Save shishirthedev/200e6da5dc04875bf8a9042352fdcd2b to your computer and use it in GitHub Desktop.

Select an option

Save shishirthedev/200e6da5dc04875bf8a9042352fdcd2b to your computer and use it in GitHub Desktop.
import UIKit
@IBDesignable class RoundButton: UIButton {
override func layoutSubviews() {
super.layoutSubviews()
updateCornerRadius()
}
@IBInspectable var rounded: Bool = false {
didSet {
updateCornerRadius()
}
}
func updateCornerRadius() {
layer.cornerRadius = rounded ? frame.size.height / 2 : 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment