Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Stacklayout in frame "bleeds" outside of frame's rounded corners in iOS #2405

Open
PaulVrugt opened this issue Apr 9, 2018 · 15 comments
Open
Labels
e/3 🕒 3 help wanted We welcome community contributions to any issue, but these might be a good place to start! m/high impact ⬛ p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@PaulVrugt
Copy link

Description

When a stacklayout with a background color is put at the top inside a frame with rounded corners, the edges of the stacklayout "bleed" outside of the rounded corners of the frame. This happens in iOS, not on android, where the behavior is correct.

Steps to Reproduce

  1. Open the test project

  2. Build the project and deploy on ios and android

  3. note the difference

Expected Behavior

Stacklayout corners should not bleed outside of the frame

Actual Behavior

Stacklayout corners bleed outside of the frame

Basic Information

  • Version with issue:
  • Last known good version: ?
  • IDE: Visual studio 2017
  • Platform Target Frameworks:
    • iOS: any
  • Nuget Packages: -

Screenshots

Android:
screenshot_20180409-115043-0

iOS:
ios

Reproduction Link

FrameBleed.zip

@HelloMyDevWorld
Copy link

the same issue also in UWP

@KSemenenko
Copy link
Contributor

The same issue on iOS and UWP

@rtimm17
Copy link

rtimm17 commented Jun 21, 2018

Seeing this currently in Xamarin.Forms v3.0.0.561731 on iOS

@KSemenenko
Copy link
Contributor

Xamarin.Forms v3.1 has this bug too.

@KSemenenko
Copy link
Contributor

@pauldipietro Any updates? I think this bug affects work of lots of people.

@samhouts samhouts added the e/3 🕒 3 label Aug 1, 2018
@paguemenos
Copy link

Any updates ? how to use a palliative solution ?

@dgonzalezp
Copy link

Its still happening, any workaround?

@mariajoserabaza-zz
Copy link

mariajoserabaza-zz commented Feb 25, 2019

Hi! At work we had the same problem. We found this workaround. In xaml you just have to use it like this:

        <StackLayout.Effects>
            <views:FrameCornerRadius CornerRadius="{OnPlatform Android='10', iOS='15'}" />
        </StackLayout.Effects>

I hope this help you.
Regards

@mkieres
Copy link
Contributor

mkieres commented Feb 26, 2019

@mariajoserabaza Thanks for sharing your gist, it indeed works. However, you've created corner radius effects for Android and iOS, whereas (at least in my case) the problem was happening only for iOS. For those of you who want to stay as minimalistic in your effects/renderers changes I suggest to create only iOS effect and set MasksToBounds to true(docs & SO post). Following @mariajoserabaza sample, you could have your iOS effect look like this:

public class FrameCornerRadiusEffect : PlatformEffect
{
	protected override void OnAttached()
	{
		Container.Layer.MasksToBounds = true;
	}

	protected override void OnDetached()
	{
	}
}

@ult-ghasan
Copy link

I have just set IsClippedToBounds to true for the frame in FrameBleed project, and it magically works on iOS, even though it is not required for Android.

Interesting behavior, maybe a number of things have changed since the bug was originally posted. Even though it works now, the behavior is still inconsistent.

@Markus2807
Copy link

@ult-ghasan you saved my day. Best solution is to write own FrameRender and set
Element.IsClippedToBounds = true;
Now Android and iOS will look same

@raver99
Copy link

raver99 commented Jun 26, 2019

IsClippedToBounds works partially for me.
It is only a workaround if you set it on the frame itself.
But then the shadow effect of the frame does not work anymore.

@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Jan 1, 2020
@matibak
Copy link

matibak commented Mar 3, 2020

Setting MasksToBounds = true in iOS custom renderer also results in lack of shadows.
Tested on Xamarin.Forms 4.5.0.356

@matibak
Copy link

matibak commented Mar 3, 2020

IsClippedToBounds works partially for me.
It is only a workaround if you set it on the frame itself.
But then the shadow effect of the frame does not work anymore.

As a workaround add another layer of Frame that would just have IsClippedToBounds = true keeping a separate layer of Frame that provides the shadow

@samhouts samhouts removed the inactive Issue is older than 6 months and needs to be retested label Mar 3, 2020
@gjmoyer
Copy link

gjmoyer commented Jul 9, 2020

I am unable to get the work arounds to resolve the issue on iOS with 4.6.0.847. Setting IsClippedToBounds = True appears to work when the view is initially presented, but when you dynamically change the view (as I have to do), then the CornerRadius on the Frame has no effect. Using the FrameCornerRadiusEffect makes no difference. I can see when debugging that the Container.Layer.MasksToBounds = true already before it is set in the OnAttached. In my case I have a label inside a frame that I am adding to children in C# code. I was able to round the corners on the label of iOS and left the rounded corners on the Frame for Android. This is what I applied to label in iOS
Container.Layer.MaskedCorners = CACornerMask.MaxXMaxYCorner | CACornerMask.MaxXMinYCorner | CACornerMask.MinXMaxYCorner | CACornerMask.MinXMinYCorner;
Container.Layer.CornerRadius = 10;
Container.Layer.MasksToBounds = true;
Container.ClipsToBounds = true;

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e/3 🕒 3 help wanted We welcome community contributions to any issue, but these might be a good place to start! m/high impact ⬛ p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
None yet
Development

No branches or pull requests