Tutorial by Examples

To create a UIImageView programmatically, all you need to do is create an instance of UIImageView: //Swift let imageView = UIImageView() //Objective-C UIImageView *imageView = [[UIImageView alloc] init]; You can set the size and position of the UIImageView with a CGRect: //Swift imageView...
You can assign an image to a UIImageView during initialization, or later using the image property: //Swift UIImageView(image: UIImage(named: "image1")) UIImageView(image: UIImage(named: "image1"), highlightedImage: UIImage(named: "image2")) imageView.image = UII...
You can animate a UIImageView by quickly displaying images on it in a sequence using the UIImageView's animation properties: imageView.animationImages = [UIImage(named: "image1")!, UIImage(named: "image2")!, UIImage(nam...
This example shows, how to make a UIView or UIImageView, rounded with some radius like this: Objective-C someImageView.layer.cornerRadius = CGRectGetHeight(someImageView.frame) / 2; someImageView.clipsToBounds = YES; Swift someImageView.layer.cornerRadius = someImageView.frame.height/2 // ...
This makes image masked to the shape of the letters of the label: Objective-C self.maskImage.layer.mask = self.maskLabel.layer; self.maskImage.layer.masksToBounds = YES; Swift 3 maskImageView.mask = maskLabel maskImageView.masksToBounds = true Here is the result:
//Swift imageView.tintColor = UIColor.redColor() imageView.image = imageView.image?.imageWithRenderingMode(.AlwaysTemplate) //Swift 3 imageView.tintColor = UIColor.red imageView.image = imageView.image?.withRenderingMode(.alwaysTemplate) //Objective-C imageView.tintColor = [UIColor redCol...
The content mode property of a view tells how its content should be laid out. In the Interface Builder, the various modes can be selected in the Attributes Inspector. Let's use two image views to see how the various modes work. Scale to Fill The image heights and widths are stretched to mat...

Page 1 of 1