0

我正在使用以下代码截取屏幕截图:

UIGraphicsBeginImageContext(contentView.frame.size);
[contentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, self,@selector(savedImage:didFinishSavingWithError:contextInfo:),nil);

这样做的问题是它似乎没有UILabel's正确地捕捉到我的圆角。

lbl.layer.cornerRadius=radius;

应该是这样的:

在此处输入图像描述

这是捕获视图时的显示方式:

在此处输入图像描述

发生了什么事??我已经尝试过组合但没有任何效果maskToBoundsclipsToBounds也许有另一种方法可以捕捉圆角的视图。

感谢您的任何建议!

4

1 回答 1

0

在初始化UIGraphicsBeginImageContext时尝试使用视图的边界

例如:

 UIGraphicsBeginImageContextWithOptions(contentView.bounds.size, NO, 1.0); //retina res
于 2013-07-08T09:43:30.547 回答