【发布时间】:2023-03-05 12:58:01
【问题描述】:
我有用于签名的可绘制文本, 我希望此上下文以具有特定路径的 png 格式保存,但我不能这样做。我希望我的绘制图像以 png 格式保存,我可以在任何地方使用
**Code for png format and path**
NSData *imageData = UIImagePNGRepresentation(_SignatureView.signatureImage);
NSString *imagePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"/imageName.png"];
[imageData writeToFile:imagePath atomically:YES];
_SignatureView is a property and signatureImage is a method
**code of signature image method**
- (UIImage *)signatureImage
{
if (!self.hasSignature)
return nil;
UIImage *screenshot = [self snapshot];
return screenshot;
}
【问题讨论】:
标签: ios objective-c nsdata