0
進出口試圖呈現視圖的圖像, 的Ive以下這個例子: Render a full UIImageView to a bitmap image的OBJ-C使用renderInContext
以及其它。
我的問題是,當我站上罰球線
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
我得到一個警告,指出「-instance法‘-renderInContex:’未找到
每一個例子,我看到呈現視圖。到圖像使用此行,爲什麼我的例子不工作
繼承人的全碼:?
-(void)RenderViewToImage:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *bitmapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSArray *documentsPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentsPaths objectAtIndex:0];
[UIImagePNGRepresentation(bitmapImage) writeToFile:[documentsDir stringByAppendingString:@"num1.png"] atomically:YES];
}