What does “autoresize = W+H;” mean in NSLog output of a UIView object

回眸只為那壹抹淺笑 提交于 2019-12-10 23:44:00

问题


Code: NSLog(@"[self view] = %@", [self view]);

Output: [self view] = <UIView: 0xca2bfc0; frame = (0 44; 320 588); autoresize = W+H; autoresizesSubviews = NO; layer = <CALayer: 0xca1d7e0>>

I tried to [[self view] setFrame:CGRectMake(0, 64, 320, 568 + 64)];, but view's frame is still frame = (0 44; 320 588). So I NSLog the [self view] to see if there is some autoresize constraints there. But don't know what does the above notation mean.


回答1:


This is the log description of the UIView -autoresizingMask. Basically, it's the way you describe what subviews should do when the superview is resized. It's very powerful.

Your current rules tell the subview to resize width and height when the superview is resized, and to keep the distance above and below the subview static (in terms of the superview coordinate system).




回答2:


You can read that as:

This view will autoresize by stretching its width and its height.




回答3:


This means that your current autoresizing mask is set to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight



来源:https://stackoverflow.com/questions/20377760/what-does-autoresize-wh-mean-in-nslog-output-of-a-uiview-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!