开发者

Resizing of subviews

开发者 https://www.devze.com 2023-01-06 15:46 出处:网络
I have a UIView, which contains a UIImageView subview. The subview fills the parent view frame. I am zooming the parent UIView from a point in the center of the screen, from a width and height of 0,

I have a UIView, which contains a UIImageView subview. The subview fills the parent view frame.

I am zooming the parent UIView from a point in the center of the screen, from a width and height of 0, 0 up to full size.

The subview won't stretch to fill the par开发者_如何学编程ent, it just remains full size the whole way through.

I've tried various combinations of contentMode and contentStretch, but nothing I do seems to work.

Help gratefully received.


If by zooming you mean animating the superviews frame, you have to set up autoresizing correctly. The superview must be set to do autoresizing:

superview.autoresizeSubviews = YES;

... while the image view must have its mask set up correctly:

imageview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
0

精彩评论

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