How to add border to a UIImage which has content mode set to aspect fill

551 views Asked by At

I have set photoImageView.contentMode = UIViewContentMode.ScaleAspectFill. I want to put a border for the image. But since the content mode is AspectFill, I don't know how to programmatically add a border just to the image. Is there any way to do this? I use Swift 2 and Xcode beta 4

1

There are 1 answers

0
Simone On

Hi Jms i came up with few lines of code (I'm on beta 5,but i don't think there s difference)

@IBOutlet weak var image: UIImageView!

image.layer.borderColor = UIColor.blackColor().CGColor
image.layer.borderWidth = 4
image.clipsToBounds = true

Worked perfectly on my image, hope will help you.