iOS SDK property of UIView: used to determine how a view lays out its content when its bounds change.
Questions tagged [contentmode]
74 questions
3
votes
1 answer
My ImageView's content mode stop working after I draw something on the image
Thanks for your time.
The image is fine before I tap the image, and then the image is compacted after I tap it.
Here is my code:
I am not using storyboard, so I create everything with code, here is the ImageView. And I added the constraints with…

Bryce Chan
- 1,639
- 11
- 26
3
votes
1 answer
Scaling down a UIButton's background image when using initWithFrame:
This is the first time I have ever designed an iOS app so I want to make sure I understand this behavior correctly.
I designed a custom bar button icon for a navigation bar in Photoshop. The final image that I saved in Photoshop was 102 x 45, and…

user3344977
- 3,584
- 4
- 32
- 88
3
votes
0 answers
Content Mode of UIImage effects image
I have 2 images that are exactly the same, just different colors. I use them to set 2 UIImageViews images. I am trying to create a progress effect and my view hierarchy looks like this
UIView >UIImageView
> UIView > UIImageView
All of the…

some_id
- 29,466
- 62
- 182
- 304
2
votes
2 answers
UIImage content mode aspectFit and bottom
Is it possible to set the contentMode for my UIImage to .scaleAspectFit and .bottom simultaneously ?
This is how my image looks like at the moment:
UIImageView:
let nightSky: UIImageView = {
let v = UIImageView()
v.image = UIImage(named:…

Chris
- 1,828
- 6
- 40
- 108
2
votes
1 answer
Setting content mode for something besides UIImageView in iOS
This answer shows the various effects of setting the content mode of a UIImageView.
Since UIView also has a content mode setting in the Interface Builder, I want to know why setting it doesn't affect any subviews that are in it.
Here is an example…

Suragch
- 484,302
- 314
- 1,365
- 1,393
2
votes
1 answer
iOS Swift - UIImageView can't set ContentMode
I'm using a CIFilter to add a filter to an image. The resulted image after filtering the image has this size: CGRectMake(10, 10, 70, 70). I can't set the resulted image content mode to ScaleAspectFill. Here is the code:
filter2image.frame =…

Robert Constantinescu
- 349
- 6
- 20
2
votes
1 answer
AspectFill does not fill the UIImageView
I have a button that has contentMode set to UIViewContentModeScaleAspectFill. I set it like this:
self.itemImage.imageView.contentMode = UIViewContentModeScaleAspectFill;
I also set it to Mode - Aspect Fill in IB for the button, just in case. And…

artooras
- 6,315
- 9
- 45
- 78
2
votes
3 answers
How to do a custom layout of a UIView so it works with both iPhone 5 screen dimensions as well as regular screen dimensions
Here is the desired outcome. The blue area is the UIView of interest. The UIView is not a UIImageView.
I've tried all sorts of arrangements with auto-resizing masks to no avail

nvrtd frst
- 6,272
- 4
- 28
- 34
2
votes
0 answers
UIImageView doesn't obey it's content mode
I am designing an iOS App where there is a View controller with an embedded view controller in view at the bottom, and an image at the top. However, I'm having problems with the Image view. Without image view, everything is OK. When I put the image…

Can Poyrazoğlu
- 33,241
- 48
- 191
- 389
2
votes
3 answers
UiimageView adapted in a uiview
I have a little problem with my UIImageView.
I want the content of UIImageView don't overflow to UIView.
When I tryed this code, I have this result, but I won't a image in area striped.
UIView *view = [[UIView alloc] init];
[view…

VivienCormier
- 1,133
- 1
- 11
- 16
2
votes
2 answers
UIImageView in ModalViewController is Ignoring ContentMode - iPhone
I am presenting a modal view with a UIImageView set to content mode fill scale (via the xib). I am setting a UIImage in the modal view class with a thumbnail from the parent class :
NSURL * finishedMovie = [self…

GuybrushThreepwood
- 5,598
- 9
- 55
- 113
1
vote
1 answer
SF Symbol does not work well with scaleAspectFill
I noticed that SF symbol doesn't really work well with scaleAspectFill.
For instance, given a circular aspect fill UIImageView with a thin border, setting its image to UIImage(systemName: "person.crop.circle.fill") would look like the following.…

Jack Guo
- 3,959
- 8
- 39
- 60
1
vote
1 answer
Why does Text expand when changing contentMode of an Image inside a ZStack?
I have a SwiftUI View that looks like this:
@State var showFullScreen: Bool = false
ZStack {
Image(uiImage: image)
.resizable()
.aspectRatio(contentMode: showFullscreen ? .fill : .fit)
.padding(showFullscreen ? 0 : 16)
…

christophriepe
- 1,157
- 12
- 47
1
vote
1 answer
Why UIImageView when its content mode is .scaleAspectFill in portrait pictures goes over its constraints?
I'm creating an image gallery using ImageView and CollectionView. Everything is working fine but portrait mode pictures go over constraints. Why is that?
myPicture = UIImageView(image: myArray[0])
view.addSubview(myPicture)
…

Tigran
- 235
- 5
- 14
1
vote
0 answers
iOS how to handle image upscaling,downscaling,image stretching and other issues
I have an image which is completely red but there is a small line which is white in color and mid of the screen.But the line disappears as its getting downscaled I believe.
so if I my imageview width is 20 by 20.my 1x image should be 20* 20 and my…

Rajan M
- 345
- 3
- 22