Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

Xamarin Forms Frame iOS Shadow gets reset [Bug]

Open Nostordamus opened this issue 4 years ago • 5 comments

Description

I was following the "VisualElement Drop Shadows on iOS" tutorial to add shadow to a <Frame> 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 <Frame> 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

  • Version with issue: Xamarin.Forms 4.7.1080
  • Last known good version: Don't know
  • IDE: Visual Studio for Mac version 8.6.5 (build 23)
  • Platform Target Frameworks: Xamarin.iOS
    • iOS: 13.18.2.1
  • Nuget Packages: Xamarin.Forms 4.7.01080, Xamarin.Forms.Essentials (1.5.3.2), Xamarin.Forms.Maps(4.7.0.1080)
  • Affected Devices: Tested on Emulators, iPhone 7

Screenshots

Before minimizing: image After resuming: image

Nostordamus avatar Jul 13 '20 13:07 Nostordamus

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

PureWeen avatar Jul 27 '20 18:07 PureWeen

still happening. Need help.

samt1925 avatar May 31 '21 19:05 samt1925

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?

skadookkunnan avatar Jul 06 '21 02:07 skadookkunnan

work around is to override SetupLayer and reapply your shadow settings

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

this.RenderShadow();

} `

minhjamin avatar Jul 15 '21 22:07 minhjamin

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

gregwoodsit avatar Nov 16 '21 00:11 gregwoodsit