Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a custom border around a UIView?

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?

like image 980
Josh Wang Avatar asked Nov 01 '22 14:11

Josh Wang


1 Answers

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.

like image 85
Jonathan Arbogast Avatar answered Nov 14 '22 03:11

Jonathan Arbogast