Created
November 22, 2018 05:50
-
-
Save amannayak0007/04c0b17593db85e78b69356a21c9b15a to your computer and use it in GitHub Desktop.
Dashed Border around UIView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dashed Border