开发者

What does this mean? initWithFrame:CGRectZero]

I created 开发者_高级运维switch in cellForRowAtIndexPath like this.

UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];

CGRectZero is equivalent to CGRectMake(0,0,0,0). But, switch is seen in normal size. I didn't specified actuall size. Please explain to me how above code works.


UISwitch is not customizable, this also applies to the size.

UISwitch overrides initWithFrame: and enforces a size appropriate for the control. The size components of the given rectangle are ignored.


Any UIView object can override the frame size by implementing the sizeThatFits: method of UIView. In fact the UIView class reference says that:

a UISwitch object returns a fixed size value that represents the standard size of a switch view

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜