开发者

autoresizingMask for fixed margin sizes

In a view containing several subviews, one of the subviews should remain a fixed, non-zero distance from the top and bottom of the superview. In these images, this view is shown in gray:

autoresizingMask for fixed margin sizes

autoresizingMask for fixed margin sizes

According to the documentation, this view should have a mask of UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth. However, this causes the view to expand it开发者_Go百科s height to take over the entire superview. How can the view be contained to fixed, but non-zero margins? Thanks.


UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth should work.

However, there's a bug with UIView auto-sizing when the parent view's height/width become small (and everything breaks when it becomes zero) — it might just be that UIView height/width can't go negative.

I've come across this problem when doing initWithFrame:CGRectZero; it might also happen if you use something like subview.frame = self.bounds when self.bounds is CGRectZero (or otherwise small).

My bruteforce debugging method would be to override setFrame: and setBounds: to add an NSLog.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜