【发布时间】:2016-04-06 19:21:40
【问题描述】:
我正在尝试截取我的 UIImageView 和其上的 UILabel 的屏幕截图。
到目前为止,我在 ImageView 中抓取 UIImage,然后在其上渲染叠加层,但 UILabel 的定位都是错误的。我将捕获的大小设置为实际图像大小(这不是我想要的)。
我只是希望能够截取屏幕上显示的确切内容。
CGSize imageSize = self.imageFromOtherView.size;
// define the size and grab a UIImage from it
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
[self.imageFromOtherView drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)];
[self.socialLabel.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
【问题讨论】:
-
您想要获取整个窗口的屏幕截图还是仅屏幕上的图像?从您的问题中很难看出。
标签: ios objective-c iphone uiimageview screenshot