-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] Fix Border Content clipping issues #10964
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing with the original posters XAML
and the results seem off
<VerticalStackLayout>
<Border StrokeThickness="20"
Stroke="Silver"
Background="White"
Margin="0"
Padding="0">
<Border.StrokeShape>
<RoundRectangle CornerRadius="30" />
</Border.StrokeShape>
<Grid HeightRequest="30" BackgroundColor="Green">
<StackLayout Orientation="Horizontal">
<Frame Padding="0" HasShadow="false"
BackgroundColor="Maroon"
CornerRadius="20"
HeightRequest="40"
WidthRequest="40" VerticalOptions="Center" >
</Frame>
<Label Text="Parameters"
VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
FontSize="Medium" FontFamily="Bold"
HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
<Frame Padding="0" HasShadow="false" CornerRadius="0" Margin="0,0,-20,0"
BackgroundColor="Blue"
HeightRequest="40"
WidthRequest="40" VerticalOptions="Center" >
</Frame>
</StackLayout>
</Grid>
</Border>
</VerticalStackLayout>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My last comment run on iOS was incorrect. I'm not sure why I got that result.
What I'm curious about now is some of the math and results here. I'm not super strong in this area so I'm probably missing something
iOS
I don't quite understand why we're multiplying the line width by 2. From the docs the line width straddles the path
https://developer.apple.com/documentation/coregraphics/1455270-cgcontextsetlinewidth?language=objc
The default line width is 1 unit. When stroked, the line straddles the path, with half of the total width on either side.
So, instead of doubling the width should we be increasing the width/height so we don't have to multiply by 2?
The iOS results don't seem quite correct because the blue frame is a rectangle but it's getting a circle cut out of it. It seems like that blue should be filling all this space.
Android
The issue I'm seeing with Android should probably be a new issue. If it is indeed an issue.
If you look at android it seems like the way the path works is the same as iOS.
The path of the border overlaps the surrounding grid which is basically what @rmarinho seems to have noticed here
#10964 (comment)
You can also see that the full height of the Border
is 70 dp but due to the border not filling in that space you end up with white space.
It feels like
- Android needs to be fixed so the width/height of the border bounds is increased by another
BorderWidth
of size - iOS should do the same and the stroke thickness shouldn't be multiplied by 2
return path; | ||
} | ||
|
||
internal PathF GetInnerPath(float strokeWidth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We was clipping using the Border shape. That is correct in many cases but not always. Using a RoundRectangle, the Corner Radius value is not the same in the inner or outer. We want in this case user the inner value. For that reason, added a new method returning the same shape but with different radius.
Alright, I think the key piece of information I was missing here is that you need to rebase to see these results. Here it is running on catalyst with everything rebased to main |
Would be massively in favour of a backport of these fixes! |
Couldn't agree more, for whatever it's worth. |
I am still having the problem. Hope the fix will be available soon. |
Agree. |
Sorry if this is a dumb question, but will these changes be in the next update? |
I feel it will be .NET 8 preview 7 or so |
Description of Change
Fix Border Content clipping issues.
Issues Fixed
Fixes #6986
Fixes #10724
Fixes #7521
Fixes #10478
Fixes #12580
Fixes #9952
Fixes #9081
Fixes #13388
Fixes #13011
Fixes #11152