Ios 截图调用drawRect

Ios 截图调用drawRect,ios,uiview,screenshot,drawrect,Ios,Uiview,Screenshot,Drawrect,我正在拍摄当前视图的屏幕截图: UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; self.bitmapImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 在某些情况下,这会调用-dra

我正在拍摄当前视图的屏幕截图:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
self.bitmapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
在某些情况下,这会调用
-drawRect:
,但并不总是这样。为什么呢


p、 这似乎是一种错误行为。

尝试将self.bounds.size更改为self.frame.sizeself.bounds.size=self.frame.size,这样就没关系了。