iOS:UIView属性、方法及相关

==================方法============

- (void)drawRect:(CGRect)rect;Draws the receiver’s image within the passed-in rectangle.

            参数说明,rect:The portion of the view’s bounds that needs to be updated. The first time your view is drawn, this rectangle is typically the entire visible bounds of your view. However, during subsequent drawing operations, the rectangle may specify only part of your view.

            调用时候:when a view is first displayed or when an event occurs that invalidates a visible part of the view. You should never call this method directly yourself. To invalidate part of your view, and thus cause that portion to be redrawn, call the setNeedsDisplay or setNeedsDisplayInRect: method instead。

Discussion

1.The default implementation of this method does nothing.

2.If you subclass UIView directly, your implementation of this method does not need to call super. However, if you are subclassing a different view class, you should call super at some point in your implementation。

------备注:

--1.关于UIViewController的View属性frame大小:[[ViewController alloc]init] 之后,如果Status bar 是不显示的(Status bar is initially hidden属性),则它的frame为(0.000000,0.000000,480.000000,320.000000)反之为(0.000000,20.000000,460.000000,320.000000)。,所以这会造成有的时候,一个控制器视图add另一个控制器视图后,上面有一条缝隙。
      另:如果一个控制器viewController被UINavigationController初始化initWithRootViewController了,然后即使viewController的视图frame设置特定值了,但如果addSubview是navigationController.view 那之前的frame值没起到作用。
      所以当view上面有缝隙的时候,有可能是view的frame默认高度为20,也有可能你修改了view的frame默认高度为0,但显示还是navigationController.view。
      如果控制器视图显示navigationController.view,则可能会出现俩个navigationbar的样子。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值