Best way to draw border on UIImageView

Discussion in 'iOS Programming' started by jschulbach, Jul 15, 2010.

  1. macrumors newbie

    Joined:
    Jun 29, 2010
    #1
    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?
     
  2. thread starter macrumors newbie

    Joined:
    Jun 29, 2010
    #2
    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.
     
  3. macrumors 65816

    Joined:
    Jul 6, 2007
    #3
    That's a neat and easy solution! I would've been bordering my images instead of this simple idea. :) Thanks for posting.
     
  4. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    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.
     

Share This Page