创建 UIView 图像时出现问题
我想创建 UIWebView 的 UIImage,然后绘制该图像。
这是我的代码:
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)];
tempView.backgroundColor = [UIColor blueColor];
UIGraphicsBeginImageContext(tempView.bounds.size);
[tempView drawRect:tempView.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
CGContextDrawImage(ctx, imageRect, [image CGImage]);
但它除了空白页之外没有绘制任何内容。我们不能像那样创建 UIImage 还是我在代码中的某个地方做错了什么?
谢谢
I want to create an UIImage of UIWebView and then I want to draw that image.
Here is my code:
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)];
tempView.backgroundColor = [UIColor blueColor];
UIGraphicsBeginImageContext(tempView.bounds.size);
[tempView drawRect:tempView.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
CGContextDrawImage(ctx, imageRect, [image CGImage]);
but its not drawing anything other than a blank page. Cant we create UIImage like that or Am I doing something wrong somewhere in the code.
Thanx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下一个代码应该可以工作:
The next code should work: