Created
April 4, 2019 14:18
-
-
Save SergLam/22df153b356975709d425f947853cf81 to your computer and use it in GitHub Desktop.
UIBezierPath border color
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
// Add border | |
let gradient = CAGradientLayer() | |
let size = CGSize(width: avatarSize, height: avatarSize) | |
let rect = CGRect(origin: .zero, size: size) | |
gradient.frame = CGRect(origin: CGPoint.zero, size: size) | |
gradient.colors = [UIColor.blue.cgColor, UIColor.green.cgColor] | |
let shape = CAShapeLayer() | |
shape.lineWidth = 5 | |
shape.path = UIBezierPath(rect: rect).cgPath | |
shape.strokeColor = UIColor.black.cgColor | |
shape.fillColor = UIColor.clear.cgColor | |
gradient.mask = shape | |
chatOpponentAvatar.layer.addSublayer(shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much!
Helped me too 🧡