View Full Version : Best way to draw border on UIImageView
Jul 15, 2010, 05:00 PM
I've got a couple of UIImageViews that are square but contain either tall or wide images with aspect fill so they fill the square. If I wanted a border around these images what is an easy way to do that? I didn't see a border option for image views in IB so would I want to just put another image view behind them that is 1px larger in each direction? What is the best way to go about adding the border?
Jul 15, 2010, 05:53 PM
I think I found a good solution. I just used a view with the background color set to my border color, sized 1px larger than the UIImageView on each side. I was mostly concerned about efficiency and what method would affect performance the least but this method seems pretty simple.
Jul 16, 2010, 10:53 AM
That's a neat and easy solution! I would've been bordering my images instead of this simple idea. :) Thanks for posting.
Jul 16, 2010, 04:04 PM
You could try playing with the image view's layer which has a borderColor and borderWidth property, but that may not work on the UIImageView.