【发布时间】:2015-05-22 08:07:29
【问题描述】:
我正在尝试以编程方式拍摄 Group 元素及其内容(文本标签)的快照并将其保存到相机胶卷。
我通常会为 iPhone 应用程序执行类似的操作(参见代码 sn-p),但使用 WatchKit 时,Group 元素的结构与 UIView 不同。
任何帮助将不胜感激。这是我的代码:
// grab reference to the area you'd like to capture
WKInterfaceGroup *theArea = _theGroup;
// define the size and grab a UIImage from it
UIGraphicsBeginImageContextWithOptions(theArea.bounds.size, theArea.opaque, 0.0);
[theArea.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screengrab = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// save screengrab to Camera Roll
UIImageWriteToSavedPhotosAlbum(screengrab, nil, nil, nil);
【问题讨论】:
标签: ios objective-c watchkit apple-watch wkinterfacegroup