Skip to content

Instantly share code, notes, and snippets.

@kevin49999
Last active July 11, 2017 16:38
Show Gist options
  • Select an option

  • Save kevin49999/67ecdf00f4fc5444e52ee13844c1fcdf to your computer and use it in GitHub Desktop.

Select an option

Save kevin49999/67ecdf00f4fc5444e52ee13844c1fcdf to your computer and use it in GitHub Desktop.
Fixes performance issues (ex: color blended layers) caused by setting layer.cornerRadius to achieve rounded corners
class PerformantButton: UIButton {
@IBInspectable var cleanCorner: CGFloat = 0
@IBInspectable var cleanBackgroundColor: UIColor = .white
override func draw(_ rect: CGRect) {
let path = UIBezierPath(roundedRect: bounds, cornerRadius: cleanCorner)
titleLabel?.backgroundColor = cleanBackgroundColor
cleanBackgroundColor.set()
path.fill()
// Also need to set background color to background color of parent view.. can do in IB or programmatically
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment