xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

Xamarin Forms Frame iOS Shadow gets reset [Bug] #11415

Open Nostordamus opened 4 years ago

Nostordamus commented 4 years ago

Description

I was following the "VisualElement Drop Shadows on iOS" tutorial to add shadow to a element. Everything works fine except when you minimize the app (home button click) wait few seconds then reopen it. The app is then resumed but the custom shadows that I added are replaced with default shadow.

The tutorial article url: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/ios/visualelement-drop-shadow

Steps to Reproduce

  1. Add following reference to any ContentPage tag in Xamarin Forms Xaml file - xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"

  2. Create Frame element and add following properties to it: ios:VisualElement.IsShadowEnabled="true" ios:VisualElement.ShadowColor="Purple" ios:VisualElement.ShadowOpacity="0.7" ios:VisualElement.ShadowRadius="12"

  3. Minimize the app, the app is now in background wait 5 seconds and then resume the app.

Expected Behavior

Applied shadow to the Frame should be the same as on fresh app startup

Actual Behavior

Applied shadow get reset with the default Frame shadow

Basic Information

Screenshots

Before minimizing: image After resuming: image

PureWeen commented 4 years ago

This is happening because when resuming this code runs

https://github.com/xamarin/Xamarin.Forms/blob/55401a8b1886fe2649b8bacec224a256850591f4/Xamarin.Forms.Platform.iOS/Renderers/FrameRenderer.cs#L112

which reverts the shadow settings from the platform specific

In onappearing if you toggle any of the platform specifics that should work around the issue for now

samt1925 commented 3 years ago

still happening. Need help.

skadookkunnan commented 3 years ago

The same thing is happening to us, we have a Behavior written on the Frame to adjust the shadow in iOS, However, if hide the Frame and show based on a binding condition the shadow effect gets reset to the default XF one.

Any fixes planned on this?

minhjamin commented 3 years ago

work around is to override SetupLayer and reapply your shadow settings

` public override void SetupLayer() { base.SetupLayer();

this.RenderShadow();

} `

gregwoodsit commented 3 years ago

Is there a plan to include this in the next release?