Hi every one there is a link :link and there is a sample code in it where the author use a CALayer with CAShapeLayer.What I would like is to use this CALayer like it was a uiimageView (maybe assign to a uiimageview) to be able to move it etc…
Share
You cannot change the layer type of an existing
UIView(meaning: you also can’t change the layer of anUIImageView), but drawing to a layer is pretty easy: you need to assign a delegate to yourCALayer, and that delegate needs to implement drawLayer:inContext:.Another solution might be to create a
UIViewsubclass and implement+layerClass:That way your view will use a shape layer and you might be able to simply use the usual
UIView‘sdrawRect:method. You could then access the layer via(CAShapeLayer *)[self layer]to modify it. I haven’t tried this approach, though.Edit: Explaining how the second solution would be done: