当添加厚圆形边框并将其调整为椭圆形时,在截取屏幕截图并保存为 png时UIImageView
,尖峰会添加到 的角上。UIImageView
UIImageView
1) 添加圆角边框时的默认视图
2) 调整UIImageView
为椭圆形状
3) 将屏幕截图保存为 .png 文件后
我尝试了以下代码来捕获屏幕截图
-(UIImage *)captureImage
{
//Capture entire screen
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
UIGraphicsBeginImageContextWithOptions(appDelegate.templateFlag.view.frame.size, appDelegate.templateFlag.view.opaque, 1.5);
}
else
{
UIGraphicsBeginImageContextWithOptions(appDelegate.templateFlag.view.frame.size, appDelegate.templateFlag.view.opaque, 2.0);
}
[appDelegate.viewController.vwEditorPanel.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
以下代码用于保存image
在 Doc 目录中
-(void)saveImage
{
NSData *data = [NSData dataWithData:UIImagePNGRepresentation([self captureImage])];
//Store image in document folder
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",self.strProjectId]];
[data writeToFile:savedImagePath atomically:NO];
}