Skip to content

Instantly share code, notes, and snippets.

@ferbass
Last active April 26, 2016 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferbass/32ca9991c60250eaa3637df9fde180a3 to your computer and use it in GitHub Desktop.
Save ferbass/32ca9991c60250eaa3637df9fde180a3 to your computer and use it in GitHub Desktop.
Rounded Button in Swift
import UIKit
class RoundedButton: UIButton {
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
let maskPath = UIBezierPath.init(roundedRect: self.bounds, cornerRadius: 5)
UIColor.clearColor().setFill()
maskPath.fill()
let maskLayer = CAShapeLayer()
maskLayer.frame = self.bounds
maskLayer.path = maskPath.CGPath
self.layer.mask = maskLayer
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment