bob*_*age 5 iphone objective-c
我目前有一个视图,我想将其更改为UIImage.我想这样做是因为UIImage类对于我需要做的事情要好得多.你如何捕获UIView的内容并将内容复制到UIImage中?
谢谢,
-大卫
像这样:
UIGraphicsBeginImageContext(myView.bounds.size);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *myImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
您需要包含CoreGraphics框架,并导入CALayer.h:
#import <QuartzCore/CALayer.h>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2534 次 |
| 最近记录: |