Skip to content

Instantly share code, notes, and snippets.

@sourleangchhean168
Created May 12, 2017 06:52
Show Gist options
  • Save sourleangchhean168/7f3bfd68ffff158062721c3aaaea6cf7 to your computer and use it in GitHub Desktop.
Save sourleangchhean168/7f3bfd68ffff158062721c3aaaea6cf7 to your computer and use it in GitHub Desktop.
UIButton Customization
extension UIButton{
func roundCorners(corners:UIRectCorner, radius: CGFloat){
let borderLayer = CAShapeLayer()
borderLayer.frame = self.layer.bounds
borderLayer.strokeColor = UIColor.green.cgColor
borderLayer.fillColor = UIColor.clear.cgColor
borderLayer.lineWidth = 10.5
let path = UIBezierPath(roundedRect: self.bounds,
byRoundingCorners: corners,
cornerRadii: CGSize(width: radius, height: radius))
borderLayer.path = path.cgPath
self.layer.addSublayer(borderLayer)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment