Skip to content

Instantly share code, notes, and snippets.

@amannayak0007
Created November 22, 2018 05:50
Show Gist options
  • Save amannayak0007/04c0b17593db85e78b69356a21c9b15a to your computer and use it in GitHub Desktop.
Save amannayak0007/04c0b17593db85e78b69356a21c9b15a to your computer and use it in GitHub Desktop.
Dashed Border around UIView
override func viewDidAppear(_ animated: Bool) {
addDashedBorder(voucherV)
}
func addDashedBorder(_ mainView:UIView) {
let viewBorder = CAShapeLayer()
viewBorder.strokeColor = UIColor(red:0.84, green:0.83, blue:0.71, alpha:1.0).cgColor
viewBorder.lineDashPattern = [10, 5]
viewBorder.frame = mainView.bounds
viewBorder.fillColor = nil
viewBorder.lineWidth = 5.0
viewBorder.path = UIBezierPath(rect: mainView.bounds).cgPath
viewBorder.cornerRadius = 8.0
mainView.layer.addSublayer(viewBorder)
mainView.layer.cornerRadius = 8.0
mainView.clipsToBounds = true
mainView.layer.borderWidth = 1.0
mainView.layer.borderColor = UIColor(red:0.99, green:0.98, blue:0.83, alpha:1.0).cgColor
}
@amannayak0007
Copy link
Author

Dashed Border

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment