Change UIImageView mode iPhone/iPad

2019-03-22 18:25发布

If I have an UIImageView with the mode set to center for example how can I change it to something else such as aspect fit with code?

enter image description here

2条回答
啃猪蹄的小仙女
2楼-- · 2019-03-22 19:09
imageView.contentMode = UIViewContentModeScaleAspectFit;
查看更多
我只想做你的唯一
3楼-- · 2019-03-22 19:22
yourImageView.contentMode = UIViewContentModeScaleAspectFit;

you can set it to any of the following

UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit,
UIViewContentModeScaleAspectFill,
UIViewContentModeRedraw,
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight
查看更多
登录 后发表回答