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
309
votes
35 answers

UIImageView missing images in Launch Screen on device

I have an app that supports iOS8 and later, built in Xcode 7 and I am using a XIB for a Launch Screen (I do not have launch images). The view contains a single UILabel with the app version, and 2 UIImageViews with images that are both present in…
MFW
  • 3,101
  • 2
  • 11
  • 3
228
votes
15 answers

How to animate the change of image in an UIImageView?

I have an UIImageView with an image. Now I have a completely new image (graphic file), and want to display that in this UIImageView. If I just set myImageView.image = newImage; the new image is visible immediately. Not animatable. I want it to…
dontWatchMyProfile
  • 45,440
  • 50
  • 177
  • 260
228
votes
12 answers

How to assign an action for UIImageView object in Swift

I'm trying to assign an UIImageView to an action when the user taps it. I know how to create an action for a UIButton, but how could I mimic the same behavior of a UIButton, but using a UIImageView?
user3706773
  • 2,989
  • 3
  • 15
  • 9
200
votes
10 answers

UIImageView aspect fit and center

I have an image view, declared programmatically, and I am setting its image, also programmatically. However, I find myself unable to set the image to both fit the aspect and align centre to the image view. In other words, I want the image to: Scale…
Ravi Vooda
  • 5,216
  • 5
  • 19
  • 25
186
votes
8 answers

UIGestureRecognizer on UIImageView

I have a UIImageView, which I want to be able to resize and rotate etc. Can a UIGestureRecognizer be added to the UIImageView? I would want to add a rotate and pinch recognizer to a UIImageView which would be created at runtime. How does one add…
some_id
  • 29,466
  • 62
  • 182
  • 304
167
votes
10 answers

Fade/dissolve when changing UIImageView's image

Rather than creating two UIImageViews, it seems logical to simply change the image of one view. If I do that, is there anyway of having a fade/cross dissolve between the two images rather than an instant switch?
Josh Kahane
  • 16,765
  • 45
  • 140
  • 253
159
votes
3 answers

Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

what is the difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill...?
Madhumitha
  • 3,794
  • 8
  • 30
  • 45
155
votes
27 answers

Center content of UIScrollView when smaller

I have a UIImageView inside a UIScrollView which I use for zooming and scrolling. If the image / content of the scroll view is bigger than the scroll view, everything works fine. However, when the image becomes smaller than the scroll view, it…
hpique
  • 119,096
  • 131
  • 338
  • 476
144
votes
6 answers

UIViewContentModeScaleAspectFill not clipping

I'm trying to draw some thumbnail images at a fixed size (100x100) using UIImageView. I've set the frame size of my image view to be 100x100, and set the contentMode to UIViewContentModeScaleAspectFill. My understanding is that this should cause the…
Josh Buhler
  • 26,878
  • 9
  • 29
  • 45
142
votes
13 answers

Setting Corner Radius on UIImageView not working

I'm at a bit of a loss. I've used the layer property of UIView to round the corners of multiple elements in my app. However, this one UIImageView is simply not complying. Not sure what I am missing. The UIImageView (called previewImage) is contained…
MarkPowell
  • 16,482
  • 7
  • 61
  • 77
137
votes
15 answers

How can I change the image displayed in a UIImageView programmatically?

I have an IBOutlet to a UIImageView, but when I look at the UIImageView doc, I can't see any hints about programmatically changing it. Do I have to fetch an UIImage object from that UIImageView?
Thanks
  • 40,109
  • 71
  • 208
  • 322
133
votes
9 answers

Using Tint color on UIImageView

I have my own subclass of UIButton. I add UIImageView on it and add an image. I would like to paint it over the image with a tint color but it doesn't work. So far I have: - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; …
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
130
votes
20 answers

How to compare UIColors?

I'd like to check the color set for a background on a UIImageView. I've tried: if(myimage.backgroundColor == [UIColor greenColor]){ ...} else{ ...} but that doesn't work, even when I know the color is green, it always falls into the else…
4thSpace
  • 43,672
  • 97
  • 296
  • 475
130
votes
9 answers

How do you create a UIImage View Programmatically - Swift

I'm trying to create a UIImage View programmatically, I have a new view and I tried doing this let imageName = "yourImage.png" yourview.backgroundColor = UIColor.colorWithPatternImage(UIImage(named:imageName)) this did not work because I don't know…
alex
  • 1,746
  • 6
  • 19
  • 34
130
votes
16 answers

How can I take an UIImage and give it a black border?

How can I set the border of a UIImage?
Shay
  • 2,595
  • 3
  • 25
  • 35
1
2 3
99 100