MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / snapshotView

Function snapshotView

packages/core/utils/native-helper.ios.ts:301–317  ·  view source on GitHub ↗
(view: UIView, scale: number)

Source from the content-addressed store, hash-verified

299}
300
301function snapshotView(view: UIView, scale: number): UIImage {
302 if (view instanceof UIImageView) {
303 return view.image;
304 }
305 // console.log('snapshotView view.frame:', printRect(view.frame));
306 const originalOpacity = view.layer.opacity;
307 view.layer.opacity = originalOpacity > 0 ? originalOpacity : 1;
308 UIGraphicsBeginImageContextWithOptions(CGSizeMake(view.frame.size.width, view.frame.size.height), false, scale);
309 view.layer.renderInContext(UIGraphicsGetCurrentContext());
310 const image = UIGraphicsGetImageFromCurrentImageContext();
311 UIGraphicsEndImageContext();
312 setTimeout(() => {
313 // ensure set back properly on next tick
314 view.layer.opacity = originalOpacity;
315 });
316 return image;
317}
318
319function copyLayerProperties(view: UIView, toView: UIView, customProperties?: { view?: Array<keyof UIView>; layer?: Array<keyof CALayer> }) {
320 const viewPropertiesToMatch: Array<keyof UIView> = customProperties?.view || ['backgroundColor'];

Callers

nothing calls this directly

Calls 1

setTimeoutFunction · 0.50

Tested by

no test coverage detected