You can write an extension to use it with all UIViews, for example. UIButton, UILabel, UIImageView, etc. You can customize my next method to suit your requirements, but I think it will work well for you.
extension UIView{ func setBorder(radius:CGFloat, color:UIColor = UIColor.clearColor()) -> UIView{ var roundView:UIView = self roundView.layer.cornerRadius = CGFloat(radius) roundView.layer.borderWidth = 1 roundView.layer.borderColor = color.CGColor roundView.clipsToBounds = true return roundView } }
Using:
btnLogin.setBorder(7, color: UIColor.lightGrayColor()) imgViewUserPick.setBorder(10)
Shardul Apr 17 '15 at 14:16 2015-04-17 14:16
source share