drawRect vs drawLayer:inContext

1. 

discussions:  http://stackoverflow.com/questions/4979192/ios-using-uiviews-drawrect-vs-its-layers-delagate-drawlayerincontext

2.

sample: https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/ZoomZoom/ZoomZoom.html

用到了:

-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context
{ ... }

注释:Warning this method of drawing has a significant limitation; the UIKit drawing methods are not thread-safe, and thedrawLayer:inRect: callbacks come in on background threads, therefore you must use the CoreGraphics drawing functions instead of the UIKit drawing methods.

3.

感觉前者主要用于UI视图级的,比如控件,VIEW,或view的布局,修改等

后者:layer级的,在使用自己定义的layer时才用到,相当于缓存一级或矩阵算法,比前者更低一级。只能用CG***开头的函数,不用UIVIEW的子类



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值