contentmode

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

徘徊边缘 提交于 2019-11-27 14:02:53
问题 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 nice to have a button with an image, but if there's no way to set it properly, it's not very handy... 回答1: Using iOS7/8 with auto-layout, button.imageView doesn't get scaled when button is laid out, e.g. for iPhone 6: (lldb) po button <UIButton:

UIButton doesn't listen to content mode setting?

匆匆过客 提交于 2019-11-27 10:54:32
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 setContentMode:UIViewContentModeScaleAspectFit]; [cell.contentView addSubview:firstButton]; Elsewhere, I'm telling it to clipToBounds. What I get is a crop of the center square of the image, rather than an aspect-scaled rendering of it. I've tried this lots of ways, including setting the mode property on firstButton.imageView, which also doesn't seem to work. Dave I had the same problem. I see this

UIButton doesn&#39;t listen to content mode setting?

∥☆過路亽.° 提交于 2019-11-26 15:20:13
问题 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 setContentMode:UIViewContentModeScaleAspectFit]; [cell.contentView addSubview:firstButton]; Elsewhere, I'm telling it to clipToBounds. What I get is a crop of the center square of the image, rather than an aspect-scaled rendering of it. I've tried this lots of ways, including setting the mode

Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

▼魔方 西西 提交于 2019-11-26 03:27:18
问题 what is the difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill ...? 回答1: If you are talking about UIViewContentMode , the following is from the Doc. UIViewContentModeScaleToFill Scales the content to fit the size of itself by changing the aspect ratio of the content if necessary. UIViewContentModeScaleAspectFit Scales the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.