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