1
votes

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. Remember 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.

1

1 Answers

10
votes

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

imageView.contentScaleFactor = scale;

imageView.transform = CGAffineTransformMakeScale(scale,scale);