Reputation: 305
I'm trying to make a semi-transparent border around a UIView. The idea is to show a picture but have the border cover the edge of the picture yet still allow you to see what is behind the border. I want the border to have different border-widths for the different sides. On the top i would like to have a border of 80 pts, on the bottom I want a border of 60 pts, and on the sides I want a border of 10 pts. I know that using the code :
UIView.layer.borderColor = [UIColor blueColor].CGcolor;
UIView.layer.borderWidth = 10;
will give you a uniform border of width 10 all around the inside of the UIView, but how do I set different border widths for different sides of the UIView?
Upvotes: 5
Views: 8318
Reputation: 14477
There are some work around to do this. 1. Add an image view at bottom of every thing else, or index 0. And add image with border. Add rest of views top of that by leaving boarder edges. Image can be on the top but than only Boarders should be solid, rest of image should be transparent. 2. Add your view in a view and add boarder on the super view. your view frame should be in that boarder.
Upvotes: 1
Reputation: 9650
To my knowledge, its not possible to get what you want just by using the properties of a UIView or its backing layer. You may have to use another UIView(s) which contain the specific border you want (maybe as a custom graphic) and overlay it on top of your image.
Upvotes: 1