
这是在视图中加载的实际图像:
.
但这是我如何保存图像:
有没有办法保存整个图像在NSVIEw?
这是我如何保存我的NSVIEw子类:
- (voID)save{ [self lockFocus]; NSBitmAPImageReP* rep = [[NSBitmAPImageRep alloc] initWithFocusedVIEwRect:[self bounds]]; [self unlockFocus]; NSData* data = [rep representationUsingType:NSPNGfileType propertIEs:nil]; Nsstring* string = NSHomeDirectory(); Nsstring* pth1 = [string stringByAppendingPathComponent:@"ttx.png"]; [data writetofile:pth1 atomically:YES];} 这个方法是在我想保存的视图中.
解决方法 使用 – [NSVIEw cachedisplayInRect:toBitmAPImageRep:]NSBitmAPImageReP* rep = [self bitmAPImageRepForCachingdisplayInRect:self.bounds];[self cachedisplayInRect:self.bounds toBitmAPImageRep:rep];总结
以上是内存溢出为你收集整理的objective-c – 保存NSScrollView内的整个NSView内容全部内容,希望文章能够帮你解决objective-c – 保存NSScrollView内的整个NSView内容所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)