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

Commit

Permalink
Fixed macOS Button issues with BackgroundColor, BorderColor, etc (#11438
Browse files Browse the repository at this point in the history
)

fixes #11431
  • Loading branch information
jsuarezruiz committed Jul 20, 2020
1 parent 31c2a22 commit 063fc6c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Xamarin.Forms.Platform.MacOS/Renderers/ButtonRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Xamarin.Forms.Platform.MacOS
{
public class ButtonRenderer : ViewRenderer<Button, NSButton>
{
const float DefaultCornerRadius = 6;

class FormsNSButton : NSButton
{
class FormsNSButtonCell : NSButtonCell
Expand Down Expand Up @@ -94,7 +96,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
var btn = new FormsNSButton();
btn.SetButtonType(NSButtonType.MomentaryPushIn);
btn.BezelStyle = NSBezelStyle.Rounded;
btn.BezelStyle = NSBezelStyle.RoundRect;
btn.Pressed += HandleButtonPressed;
btn.Released += HandleButtonReleased;
SetNativeControl(btn);
Expand Down Expand Up @@ -155,7 +157,7 @@ void UpdateBorder()
uiButton.Layer.BorderColor = button.BorderColor.ToCGColor();

uiButton.Layer.BorderWidth = (float)button.BorderWidth;
uiButton.Layer.CornerRadius = button.CornerRadius;
uiButton.Layer.CornerRadius = button.CornerRadius > 0 ? button.CornerRadius : DefaultCornerRadius;

UpdateBackgroundVisibility();
}
Expand Down Expand Up @@ -214,6 +216,5 @@ void HandleButtonReleased()
{
Element?.SendReleased();
}

}
}

0 comments on commit 063fc6c

Please sign in to comment.