Questions tagged [aspect-fit]
23 questions
112
votes
21 answers
UIButton won't go to Aspect Fit in iPhone
I have a couple UIButtons, and in IB they're set to Aspect Fit, but for some reason they're always stretching. Is there something else you have to set? I tried all the different view modes and none of them work, they all stretch.

marty
- 1,137
- 2
- 7
- 7
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
8
votes
2 answers
Xcode Imageview Aspect Fit Remove Extra Space
I have an imageview inside a UITableViewCell.
Imageview with Aspect Fit creates a lot of extra space in the top and bottom if the image is large. The extra space (gray background color) is shown in the picture below.
How do I remove the extra…

hmzfier
- 554
- 9
- 21
5
votes
3 answers
Is there a way to make a NativeScript GridLayout with a fixed aspect ratio?
First of all, I'd like to apologize if I fail to comply with any SO rules, as it's my first question.
What I'm trying to acomplish, is having a square gridLayout in my page. The behavior should be equivalent to having an element with…

Uka Lpts
- 121
- 1
- 10
4
votes
3 answers
Aspect fit programmatically in iOS?
I want to insert one view into another with aspect fit option. But I can't just set contentMode for some reasons.
Could you provide a solution via resizing of the inner CGRect according to the outer CGRect?
And yes, there are a lot of similar…

Vyachaslav Gerchicov
- 2,317
- 3
- 23
- 49
4
votes
3 answers
how to set image in top avoiding space in UIimageView
I've an UIImageView with content mode Aspect Fit of size 220x155. I'm dynamically inserting different images in different resolutions, but all larger than the size of the UIImageView. As the content mode is set to Aspect Fit, the image is scaled…

Hiren
- 12,720
- 7
- 52
- 72
3
votes
0 answers
How to align UIImageView with Aspect Fit to Top?
I'm working on some screen in which at top I have an application logo: I want this logo to be resized based on the free size it has. So I configured it with the desired constraints and when it has enough space it like the desired result:
The…

Emil Adz
- 40,709
- 36
- 140
- 187
2
votes
3 answers
iOS - Swift - Clickable Regions on a UIImage
I am working on a project where I have to plot points in specific regions on an image that represents the human body. In Interface Builder, I have set up a container UIView, which takes up most of the vertical center of the main view. In that…

Moebius
- 700
- 7
- 25
2
votes
1 answer
Make an image view adjust its height to match the height of its image when the image is scaled down due to the content mode
I have an image view that is constrained in a way so that its left, right and upper edge are pinned to its superview and its bottom edge has a fixed spacing to the label below. It doesn't have any width or height constraints so it's supposed to get…

Mischa
- 15,816
- 8
- 59
- 117
1
vote
1 answer
Display aspect fit Video and Image in SKView
I was struggling to display aspect fit images using SKSpriteNode in SKView. I faced many issues, such as size issues, can't place images of specific origin, etc.
Same problem I had to display video using SKVideoNode in SKView.

Monika Patel
- 2,287
- 3
- 20
- 45
1
vote
1 answer
difference between imageview and image aspect fit ratio
I have added an Imageview on UIView, and set the property AspectToFit. According to app requirement, I need to add one more image on the imageview.
float width;
float height;
float x;
float y;
CGSize imageViewSize = …

Minkle Garg
- 723
- 3
- 9
- 35
1
vote
2 answers
Swift image Aspect Fill for tall image not working
I have this UIImageView which may contain images with different ratios.
I have studied the properties of UIImageView and it seems that the Aspect Fill property set for the Mode of the View should be what I need.
It works as intended when the image…

asheyla
- 3,175
- 5
- 18
- 34
1
vote
1 answer
What does Aspect fit mean in ios
I am studying a tutorial, and it says that we are going to set the image mode to aspect fit.
I wonder what that means?
I went to wikipeadia, and it is stated:
The aspect ratio of an image describes the proportional relationship between its width…

Marco Dinatsoli
- 10,322
- 37
- 139
- 253
1
vote
3 answers
UIImageview in custom cell with Aspect fill mode constraints issue
I have an issue with UIImageView in UITabelViewCell.
here is my UIImageView in the interface builder and it's constraints
When i set the mode "scale to fill" i got this result (which match the constraints and my expectations)
but I don't want that…

OXXY
- 1,047
- 2
- 18
- 43
0
votes
2 answers
Textfield background image Aspect fit is restricting the width in iPad in swiftUI
In iPhone designs looks fine. But in iPad, the TextField width is not increasing. And if I change the content mode to fill both fields are overlapping. How can I fix this?
var body: some View {
VStack (alignment: .center,spacing…

venkat
- 3
- 4