Tag: 不良访问不

drawRect:/ renderInContext:问题

似乎有一个问题试图将我的观点绘制到上下文中。 我的基本设置是,我有一个视图控制器,拥有一个UIPageViewController ,其中我加载控制器的视图,可以由用户的手指绘制。 基本上我有一本书可以画出来。 当书中的页面被打开时,我通过调用来保存图像 – (UIImage *)wholeImage { // Render the layer into an image and return UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *wholePageImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return wholePageImage; } 这个返回值然后被保存到一个文件。 但是,当我调用这个保存方法,然后行 [self.layer renderInContext:UIGraphicsGetCurrentContext()]; 被击中,这似乎打电话给我的drawRect:方法,这是覆盖如下, – (void)drawRect:(CGRect)rect { // Draw the current state of the image [self.currentImage drawAtPoint:CGPointMake(0.0f, 0.0f)]; CGPoint midPoint1 = [self midPointOfPoint1:previousPoint1 point2:previousPoint2]; CGPoint […]