Here is how to do UIImageView Image Inset in Apple iOS App using Xcode

Here is example if you want to inset UIImageView so that image does not fit edge to edge of the UIImageView

 
Note: Use of latest version of Xcode & Latest version of Swift Programming Language is preferred.

 
Here is step by step procedure to achieve designed result:

 
Step 01: Create Apple iOS Project in Xcode. Add UIImageView to View Controller in Storyboard.

 
Step 02: Now Connect that UIImageView to View Controller Swift File. It will look something like this.

 

@IBOutlet weak var imageView: UIImageView!

 
Step 03: Now add following code in ViewDidLoad Function of your View Controller File.

 

// Scale & Aspect Fill Image to UIImageView
imageView.contentMode = .scaleAspectFill

// Now assign image from asset catalogue & inset image
imageView.image = UIImage(named: "image-name")?.withAlignmentRectInsets(UIEdgeInsets(top: -10, left: -10, bottom: -10, right: -10))

 
Result: You should get desired result with image with inset.

 
Hope it helps,

 
Thanks & Regards
Mandar Apte

Mandar Apte

This website contains a design articles blog by Mandar Apte. He writes and shares his iOS development, graphic, web, & animation film design experience through articles. Mandar is Mumbai based multi-disciplinary designer with expertise in UI, UX, Logo, Symbol, and Brand Identity design. He is an alumnus of Sir J. J. Institute of Applied Art, Mumbai. He currently runs his studio in the heart of the city of Mumbai.

Leave a Reply

Your email address will not be published. Required fields are marked *