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

Commit 063fc6c

Browse files
authored
Fixed macOS Button issues with BackgroundColor, BorderColor, etc (#11438)
fixes #11431
1 parent 31c2a22 commit 063fc6c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Xamarin.Forms.Platform.MacOS/Renderers/ButtonRenderer.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace Xamarin.Forms.Platform.MacOS
88
{
99
public class ButtonRenderer : ViewRenderer<Button, NSButton>
1010
{
11+
const float DefaultCornerRadius = 6;
12+
1113
class FormsNSButton : NSButton
1214
{
1315
class FormsNSButtonCell : NSButtonCell
@@ -94,7 +96,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
9496
{
9597
var btn = new FormsNSButton();
9698
btn.SetButtonType(NSButtonType.MomentaryPushIn);
97-
btn.BezelStyle = NSBezelStyle.Rounded;
99+
btn.BezelStyle = NSBezelStyle.RoundRect;
98100
btn.Pressed += HandleButtonPressed;
99101
btn.Released += HandleButtonReleased;
100102
SetNativeControl(btn);
@@ -155,7 +157,7 @@ void UpdateBorder()
155157
uiButton.Layer.BorderColor = button.BorderColor.ToCGColor();
156158

157159
uiButton.Layer.BorderWidth = (float)button.BorderWidth;
158-
uiButton.Layer.CornerRadius = button.CornerRadius;
160+
uiButton.Layer.CornerRadius = button.CornerRadius > 0 ? button.CornerRadius : DefaultCornerRadius;
159161

160162
UpdateBackgroundVisibility();
161163
}
@@ -214,6 +216,5 @@ void HandleButtonReleased()
214216
{
215217
Element?.SendReleased();
216218
}
217-
218219
}
219220
}

0 commit comments

Comments
 (0)