Is it possible to create a subclass UIViewthat displays live in Xcode (by adding an attribute IB_DESIGNABLEas described here ), but does not have a custom method drawRect:?
We have a custom subclass UIViewthat uses some CAShapeLayerthat are added to self.layerfor drawing (hence, there is no need to override drawRect:). This class works fine in the application, but will not display on Xcode.
If we replicate the code in drawRect:, it works, but we would prefer that the drawing runs automatically on the layers.
Can this be done?
I also tried to do
- (void)drawRect:(CGRect)rect
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(currentContext, self.myLayer1.frame.origin.x, self.myLayer1.frame.origin.y);
[self.myLayer1 renderInContext:currentContext];
CGContextMoveToPoint(currentContext, self.myLayer1.frame.origin.x, self.myLayer1.frame.origin.y);
[self.myLayer2 renderInContext:currentContext];
}
which seems to work on the device, but not on Xcode IB.