fix: UIImage leaking after Image is disposed

This commit is contained in:
Igor Randjelovic
2022-02-16 23:10:39 +01:00
parent 1601caff4e
commit f02ce816b7

View File

@ -24,6 +24,21 @@ export class Image extends ImageBase {
this._setNativeClipToBounds();
}
public disposeNativeView(): void {
super.disposeNativeView();
if (this.imageSource?.ios) {
// release the native UIImage
CFRelease(this.imageSource.ios);
}
this.imageSource = null;
if (this.nativeViewProtected?.image) {
this.nativeViewProtected.image = null;
}
}
private setTintColor(value: Color) {
if (value && this.nativeViewProtected.image && !this._templateImageWasCreated) {
this.nativeViewProtected.image = this.nativeViewProtected.image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);