protected override void OnAttached() { try { FormsTintImageEffect effect = (FormsTintImageEffect)Element.Effects.FirstOrDefault(e => e is FormsTintImageEffect); if (effect == null || !(Control is UIImageView image)) { return; } image.Image = image.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); image.TintColor = effect.TintColor.ToUIColor(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"An error occurred when setting the {typeof(TintImageEffect)} effect: {ex.Message}\n{ex.StackTrace}"); } }
protected override void OnAttached() { try { FormsTintImageEffect effect = (FormsTintImageEffect)Element.Effects.FirstOrDefault(e => e is FormsTintImageEffect); if (effect == null || !(Control is ImageView image)) { return; } PorterDuffColorFilter filter = new PorterDuffColorFilter(effect.TintColor.ToAndroid(), PorterDuff.Mode.SrcIn); image.SetColorFilter(filter); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine( $"An error occurred when setting the {typeof(TintImageEffect)} effect: {ex.Message}\n{ex.StackTrace}"); } }