【发布时间】:2015-06-26 13:16:26
【问题描述】:
我有一个实时摄像头视图,我希望在截屏时只将其中的一部分包含在圆形 UIImage 中。我得到的只是圆形 UIImage 和白色背景。 我称圆形图像为 circleImage,相机视图为 camView:
self.camView = self.faceImage.snapshotViewAfterScreenUpdates(false)
UIGraphicsBeginImageContextWithOptions(self.circleImage.bounds.size, false, 0);
self.circleImage.drawViewHierarchyInRect(self.camView.bounds, afterScreenUpdates: true)
var image:UIImage = UIGraphicsGetImageFromCurrentImageContext()
var imageData:NSData = UIImagePNGRepresentation(image)
UIGraphicsEndImageContext();
//Save it to the camera roll
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
【问题讨论】: