| 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']; |
| 321 | const layerPropertiesToMatch: Array<keyof CALayer> = customProperties?.layer || ['cornerRadius', 'borderWidth', 'borderColor']; |
| 322 | |
| 323 | viewPropertiesToMatch.forEach((property) => { |
| 324 | if (view[property] !== toView[property]) { |
| 325 | // console.log('| -- matching view property:', property); |
| 326 | view[property as any] = toView[property]; |
| 327 | } |
| 328 | }); |
| 329 | |
| 330 | layerPropertiesToMatch.forEach((property) => { |
| 331 | if (view.layer[property] !== toView.layer[property]) { |
| 332 | // console.log('| -- matching layer property:', property); |
| 333 | view.layer[property as any] = toView.layer[property]; |
| 334 | } |
| 335 | }); |
| 336 | } |
| 337 | |
| 338 | function animateWithSpring(options?: { tension?: number; friction?: number; mass?: number; delay?: number; velocity?: number; animateOptions?: UIViewAnimationOptions; animations?: () => void; completion?: (finished?: boolean) => void }) { |
| 339 | // for convenience, default spring settings are provided |