Questions tagged [uiimageview]

An image view object provides a view-based container for displaying either a single image or for animating a series of images in iOS. For animating the images, the UIImageView class provides controls to set the duration and frequency of the animation. You can also start and stop the animation freely.

UIImageView is available in iOS 2.0 and later. New image view objects are configured to disregard user events by default. If you want to handle events in a custom subclass of UIImageView, you must explicitly change the value of the userInteractionEnabled property to YES after initializing the object. The question related can be tagged using .

When a UIImageView object displays one of its images, the actual behavior is based on the properties of the image and the view. If either of the image’s leftCapWidth or topCapHeight properties are non-zero, then the image is stretched according to the values in those properties. Otherwise, the image is scaled, sized to fit, or positioned in the image view according to the contentMode property of the view. It is recommended (but not required) that you use images that are all the same size. If the images are different sizes, each will be adjusted to fit separately based on that mode.

All images associated with a UIImageView object should use the same scale. If your application uses images with different scales, they may render incorrectly.

UIImage Class Reference

Resource:

Questions in Stack Overflow related to UIImageView:

Sample:

UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
//Allocating imageView and set its frame.

myImage.image = [UIImage imageNamed:@"myImage.png"];
//add image into imageview

[self.view addSubview:myImage];
// add imageview into your viewcontroller's view
10625 questions
78
votes
10 answers

How to set corner radius of imageView?

In Objective-C such line self.mainImageView.layer.cornerRadius = CGRectGetWidth(self.mainImageView.frame)/4.0f; does its job, I tried it in Swift using analogy self.mainImageView.layer.cornerRadius =…
theDC
  • 6,364
  • 10
  • 56
  • 98
76
votes
23 answers

"Creating an image format with an unknown type is an error" with UIImagePickerController

While choosing an image from the image picker in iOS 10 Swift 3 I am getting an error - Creating an image format with an unknown type is an error func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage,…
Jeet
  • 5,569
  • 8
  • 43
  • 75
76
votes
5 answers

What is the best way to create a shadow behind a UIImageView

I have a UIImageView that I want to add a shadow behind. I wish that apple had that as a property but they have to make lots of things hard for us programmers so I need to ask this question.
Jab
  • 26,853
  • 21
  • 75
  • 114
74
votes
5 answers

Passing through touches to UIViews underneath

I have a UIView with 4 buttons on it and another UIView on top of the buttons view. The top most view contains a UIImageView with a UITapGestureRecognizer on it. The behavoir I am trying to create is that when the user taps the UIImageView it…
Magic Bullet Dave
  • 9,006
  • 10
  • 51
  • 81
74
votes
20 answers

How to know the image size after applying aspect fit for the image in an UIImageView

I am loading an image to an imageview with mode as 'Aspect Fit'. I need to know the size to which my image is being scaled to. Please help.
Nithin
  • 6,435
  • 5
  • 43
  • 56
72
votes
8 answers

With Auto Layout, how do I make a UIImageView's size dynamic depending on the image?

I want my UIImageView to grow or shrink depending on the size of what the actual image it's displaying is. But I want it to stay vertically centered and 10pts from the leading edge of the superview. However, if I set these two constraints it…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
71
votes
10 answers

How to stop an image from stretching within a UIImageView?

I have a UIImageView where I have set the frame size to x = 0, y = 0, width = 404, height = 712. In my project, I need to change the image in UIImageView dynamically. I am using this code to change the image: self.imageView.image = [UIImage…
R. Dewi
  • 4,141
  • 9
  • 41
  • 66
69
votes
10 answers

How do I make an UIImage/-View with rounded corners CGRect (Swift)

How do I make a UIImageView with rounded corners on a Swift iOS Playground? Inside it needs to be filled with a color.
Thomas
  • 1,468
  • 4
  • 14
  • 20
66
votes
5 answers

Removing image from UIImageView

I load a UIImageView with an image depending on user interaction. When the parent view is initially displayed, no image has been selected and the imageview is black. If the user leaves that view and comes back, the image is still there. I've…
4thSpace
  • 43,672
  • 97
  • 296
  • 475
66
votes
7 answers

How to make a circular UIView

I want to make a UIView or UIImageView that is a circle. Or a circle that i can change the size of using a slider, and the color of with a pickerview.
Jab
  • 26,853
  • 21
  • 75
  • 114
66
votes
7 answers

Tiled Background Image: Can I do that easily with UIImageView?

I have a fullscreen background image that is tiled, i.e. it has to be reproduced a few times horizontally and vertically in order to make a big one. Like in the browsers on ugly home pages ;) Is UIImageView my friend for this?
Thanks
  • 40,109
  • 71
  • 208
  • 322
64
votes
8 answers

Insets to UIImageView?

I would like to achieve : Scale to fill mode of image view Insets to UIImageView so that image does not meet the edges of the UIImageView Bottomline: I want to increase the touch area of the UIImageView without stretching the image beyond certain…
Sarasranglt
  • 3,819
  • 4
  • 23
  • 36
61
votes
8 answers

UIImage aspect fit and align to top

It looks like aspect fit aligns the image to the bottom of the frame by default. Is there a way to override the alignment while keeping aspect fit intact? ** EDIT ** This question predates auto layout. In fact, auto layout was being revealed in WWDC…
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
60
votes
13 answers

UIImageView doesn't always tint template image

In the case below, there are two UIImageViews with the same settings and the same template image... But one tints the image, and one does not I duplicated working UIImageView and placed it instead of the other and it worked. This happened to me…
Zuzana Paulis
  • 941
  • 1
  • 8
  • 19
60
votes
24 answers

How to set imageView in circle like imageContacts in Swift correctly?

I want to show a picture into imageView like the image contact (in a circle) But when I try to show this, the imageView rescale his size and this doesn't show correctly in a circle. image.layer.borderWidth=1.0 image.layer.masksToBounds = false …
user3745888
  • 6,143
  • 15
  • 48
  • 97