robinmanuelthiel / flexbutton

Flexible button control for Xamarin.Forms
MIT License
240 stars 34 forks source link

CornerRadius not working in Xamarin.iOS current versions (somewhat workaround inside) #91

Closed idchlife closed 3 years ago

idchlife commented 4 years ago

Describe the bug I updated Xamarin Forms and CornerRadius no longer works.

To Reproduce Steps to reproduce the behavior:

  1. Update any project or create new with versions:

Xamarin.iOS - 13.20.1.18 Xamarin.Forms- 4.7.0.1080

  1. Run iOS project. See that buttons is not rounded if you specify CornerRadius.

Expected behavior CornerRadius to work. Buttons square as if there was no corner radius.

Screenshots

Please complete the following information:

Additional information if needed:

I fixed it in my app by providing custom ViewRenderer for iOS with this code:

[assembly: ExportRenderer(typeof(FlexButton), typeof(FlexButtonFixRenderer))]
namespace ReceiptsApp.iOS.Views.UI {
  public class FlexButtonFixRenderer : ViewRenderer {
    public FlexButtonFixRenderer() {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<View> e) {
      base.OnElementChanged(e);

      Debug.WriteLine("IM HERE");

      if (e.NewElement == null) return;

      var element = e.NewElement;

      if (element == null) return;

      Debug.WriteLine("ELEMENT IS NOT NULL!");

      try {
        if (Element is FlexButton flex) {
          Debug.WriteLine("FIXING FLEX BUTTON BUG WITH NO CORNER RADIUS");
          if (flex.CornerRadius <= 0) return;

          NativeView.Layer.CornerRadius = flex.CornerRadius;
          //NativeView.ClipsToBounds = true;

          Debug.WriteLine("DONE FIXING");
          //control.Layer.Boun

        }
      } catch (Exception exc) {
        Debug.WriteLine("ERROR FIXING FLEX BUTTON ROUND EFFECT");
        Debug.WriteLine(exc);
      }

    }
  }
}

BUT it kills border because of ClipsToBounds 😩

mike-rowley commented 4 years ago

@idchlife I think this project has been abandoned. I posted a message over 6 weeks ago asking Robin-Manuel, the repository owner, about its status and haven't received a response.

I have pulled the code repository and am making necessary changes within my own project code base, unfortunately I don't have the time or requisite control building experience to continue development on this publicly.

I have run into the issue you have described and thought I would share what I have found, it appears to be related to this Xam Forms bug: https://github.com/xamarin/Xamarin.Forms/issues/2405

robinmanuelthiel commented 3 years ago

Fixed in v0.13.0