Reputation: 4409
How to set profile Border opacity ?
How to set transparent for having opacity of border color with .white of 50% opacity.
profileView.layer.borderWidth = 3.0
profileView.layer.borderColor = UIColor.white.cgColor
Upvotes: 0
Views: 287
Reputation: 36
for alternative you can add UIView behind and set it as border of you ImageView, it's easier to set the oppacity
Upvotes: -1
Reputation: 14994
Use withAlphaComponent
:
profileView.layer.borderColor = UIColor.white.withAlphaComponent(0.5).cgColor
or:
profileView.layer.borderColor = UIColor.white.cgColor.copy(alpha: 0.5)
Obviously you can choose whatever alpha value you want in the range 0.0 to 1.0.
Or in this case you can use:
profileView.layer.borderColor = UIColor(white: 1.0, alpha: 0.5).cgColor
Upvotes: 4