Questions tagged [contentmode]

iOS SDK property of UIView: used to determine how a view lays out its content when its bounds change.

74 questions
159
votes
3 answers

Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

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

UIButton doesn't listen to content mode setting?

firstButton is a UIButton of type Custom. I'm programmatically putting three of them across each cell of a table, thusly: [firstButton setImage:markImage forState:UIControlStateNormal]; [firstButton…
Dan Ray
  • 21,623
  • 6
  • 63
  • 87
16
votes
2 answers

iOS SDK UIViewContentModeScaleAspectFit vs. UIViewContentModeScaleAspectFill

I have an image that I would like to display in a UITableViewCell using the UITableViewCellStyleSubtitle style that provides a UIImageView, and two lines of text, plus an optional accessory view. However, when I set the content mode of the…
Dalmazio
  • 1,835
  • 2
  • 23
  • 40
14
votes
2 answers

How to combine Auto Layout constraints with contentMode property of UIView

I have a UIImageView object configured with Auto Layout. I have created constraints so that the view keeps a constant distance to its superview. In visual format it would be like: @"V:|-[imageView]-|" @"H:|-[imageView]-|" But I would also like to…
elitalon
  • 9,191
  • 10
  • 50
  • 86
13
votes
3 answers

iOS >> UIButton ImageView Property >> How to set Content Mode?

Is there a way to set a UIButton Image, BackgroundImage or ImageView Properties Content Mode Property? I've tried the direct approach (it didn't work, of course...): self.imageButton.imageView.contentMode = UIViewContentModeScaleAspectFit; It's…
Ohad Regev
  • 5,641
  • 12
  • 60
  • 84
12
votes
3 answers

UIButton ignoring contentMode when highlighted (adjustsImageWhenHighlighted)

I set a UIImage for my UIButton using [myButton setImage:forState:]; and I set it's contentMode using [[myButton imageView] setContentMode:UIViewContentModeScaleAspectFit]; But when you tap the button, it goes back to UIViewContentModeScaleToFill…
Kenny Winker
  • 11,919
  • 7
  • 56
  • 78
8
votes
1 answer

UIImageView shadow and aspect-filling together

I have a UIImageView of which I'm setting the image dynamically (from a URL). The images may have arbitrary sizes/aspect ratios. I am setting contentMode to Aspect Fill and view's layer's clipsToBounds to YES, and it's displayed correctly. However,…
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
8
votes
2 answers

What type of contents UIViewContentMode mode refers to?

According to the official doc on UIView about the contentMode property: The content mode specifies how the cached bitmap of the view’s layer is adjusted when the view’s bounds change What's defined the content in this definition? Is it a sub view…
tiguero
  • 11,477
  • 5
  • 43
  • 61
6
votes
1 answer

how to auto-stretch UISegmented Control horizontally to fill full UITableViewCell?

How to auto-stretch UISegmented Control horizontally to fill full UITableViewCell? In a manner in which it will auto-resize after an orientation change too. I have tried the following however this still doesn't work. The segmented control appears…
Greg
  • 34,042
  • 79
  • 253
  • 454
6
votes
0 answers

UIImage - Content mode fit and right position - Swift 4

How can I move the image to the right? img.contentMode = .scaleAspectFit Example:
Bartek
  • 111
  • 7
5
votes
0 answers

Animation while changing the content mode for fixed view size

I am developing an iPhone application. I have an UIImageView whose size is fixed to 320x480. Initially contentmode is set to AspectFit. When I change the content mode to Aspect Fill, I would like to show the animation (Drawing frame of the image…
spd
  • 2,114
  • 1
  • 29
  • 54
5
votes
2 answers

iOS: How to align (left/right) a UIImageView when using UIViewContentModeScaleAspectFill?

I'm playing with the contentMode property of the UIImageView. When I set it to UIViewContentModeScaleAspectFill, the image is scaled to fit the screen. It's centered. So right and left (or top and bottom, depending on the screen orientation) part…
Alexis
  • 16,629
  • 17
  • 62
  • 107
4
votes
1 answer

UITableViewCell imageView.contentMode doesn't work in 3.0

In UITableViewCellStyleDefault, setting the contentMode on the imageView has no result. If I change my build SDK to version 3.1, everything again works. I don't get any warnings or errors when compiling on 3.0 but this…
Daddy
  • 9,045
  • 7
  • 69
  • 98
4
votes
1 answer

UIImageView set to imageWithData ignores contentMode

In my custom tableViewCell, I have an imageView (not the tableViewCell's default imageView) which fills the entire cell. It is set up in IB (and by code) with the contentMode UIViewContentModeAspectFill, and it clips to bounds. Whenever I change the…
Emil
  • 7,220
  • 17
  • 76
  • 135
4
votes
2 answers

How to make content non visible outside UIView

I have an UIImageView with UIViewContentModeCenter, so Images that it holds are not getting scaled or deformed. But this way if the image is larger, it can be seen outside the ImageView's frame. I don't want to crop the image (user can scale it, so…
Concuror
  • 408
  • 3
  • 9
1
2 3 4 5