【发布时间】:2014-05-05 05:56:14
【问题描述】:
我在视图上放置了一个标签,视图的框架是 CGRectMake(0,0,270,203)。现在我必须用 CGRectMake(0,0,800,600) 截屏。所以我必须将标签从旧矩形转换为新矩形。
这是我用来截屏的代码:
CGRect rect = [view bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
这是我用来转换点的代码:
CGRect f = [view convertRect:lblMessage.frame fromView:viewMessage];
但我无法从新图像中的标签获取实际位置。任何人都可以在我错的地方帮忙。
在这里,我附上了图片以进行更多说明。 在小视图中,我添加了一个标签,我必须根据大图像视图转换标签的框架。
谢谢,
【问题讨论】:
-
你的标签真的在
view里面吗?请添加有关视图层次结构的一些详细信息。请指定您希望标签在结果图像上的位置。
标签: ios objective-c cgrect cgpoint