How to autoresize sublayers

Eager Beaver picture Eager Beaver · Jan 30, 2013 · Viewed 10.2k times · Source

I have an imageview and on button click I draw some bezier paths and some text layer too. On undo, I've removed last drawn path and text layer.

Now I want to resize my image View to set up in uper half portion of view and duplicated in lower half view, and want to resize all layers at the same time and also want to continue drawing after that.

Answer

DivineDesert picture DivineDesert · May 14, 2013

Its too late to answer...

But may be this can help others. There is no autoresize masks for CALayers You can manage that with some tricks..

- (void)layoutSubviews {
  // resize your layers based on the view's new frame
  layer.frame = self.bounds;
}

This will work if you have created a subclass of UIView. If not that, you can just set the bounds to the frame of CALayer anywhere if you have reference to your layer.