开发者

how do I scale the image in a UIImageView when in "centre" mode? (change frame doesn't work)

开发者 https://www.devze.com 2023-03-21 00:57 出处:网络
Question - How do I scale the image in a UIImageView when in \"centre\" mode?(change frame doesn\'t work)I should clarify in that I would like to be able to do this programmatically.

Question - How do I scale the image in a UIImageView when in "centre" mode? (change frame doesn't work) I should clarify in that I would like to be able to do this programmatically.

I can scale the UIImageView by changing it's frame to something smaller but on and same center, and this works (I put a border on view to check), however the actual image in the UIImageView doesn't change. Rem开发者_运维问答ember the UIImageView mode has got to be "Centered".

Background: the reason I ask is because I have some images I want to scale between orientation changes, and they need to be centered, however their views can NOT have a "aspect fit" mode as some of the views are being rotated over time using a transformation, and having them auto-scale as orientation changes occur as they rotate won't work well.


Try to set the contentScaleFactor (available in iOS 4.0) or the transform property:

imageView.contentScaleFactor = scale;

imageView.transform = CGAffineTransformMakeScale(scale,scale);
0

精彩评论

暂无评论...
验证码 换一张
取 消