Can`t draw in CAlayer
HI All.
I have subclass of UIScrollView. IN this class I have added some imageView.layer
to self.layer
. And when I call [imageView.layer setNeedsDisplay]
my implemented delegate never called.
-(void)drawLayer:(CALayer*)layer :(CGConte开发者_运维知识库xtRef)context
I`ve also set
imageView.layer.delegate = self
Could anyone tell me where I must set delegate function to make this to work.
Thank you for advance.
There are some things a little bit odd with you approach.
If ou have a ScrollView and an ImageView you don't need to add the layers, you can just do
[scrollView addSubview: imageView];
Also, you don't need a delegate for drawing a UIView
into a UIWindow
.
If, however, you want to add a delegate still you can do this:
imageView.delegate =
A ImageView should not be his own delegate, you will need some ViewController, better a ScrollViewController.
The method name is
-drawLayer:inContext:
. The delegate's method signature should be like this:// vvvvvvvvv - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
Don't override the delegate of another layer attached to a view (which is that view). This will make the view cannot operate normally.
精彩评论