(view: UIView, scale: number)
| 299 | } |
| 300 | |
| 301 | function 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 | |
| 319 | function copyLayerProperties(view: UIView, toView: UIView, customProperties?: { view?: Array<keyof UIView>; layer?: Array<keyof CALayer> }) { |
| 320 | const viewPropertiesToMatch: Array<keyof UIView> = customProperties?.view || ['backgroundColor']; |
nothing calls this directly
no test coverage detected