Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] iOS: Dashed Frame stopped working in the latest XF version

Open felipemomm opened this issue 4 years ago • 3 comments

Description

Currently we have a Dashed Frame in our app and it was working flawlessly on Xamarin.Forms 4.6.0.800, however after upgrading to Xamarin.Forms 4.6.0.1141 it stopped working. The same issue happens in the latest Xamarin.Forms 4.7.*.

Steps to Reproduce

Here is the code for the iOS renderer:

<Frame Padding="20" BackgroundColor="LightBlue" BorderColor="Blue">
            <Label>
               
            </Label>
        </Frame>

public class DashedBorderedFrameRenderer : FrameRenderer
    {
        private readonly CAShapeLayer dashedBorderFrame = new CAShapeLayer();

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (Layer == null) return;

            if (e.PropertyName.Equals(nameof(Element.BorderColor)))
            {
                UpdateBorderFrame();
            }
        }

        private void UpdateBorderFrame()
        {
            dashedBorderFrame.StrokeColor = Element.BorderColor.ToCGColor();
            Layer.BorderColor = Color.Transparent.ToCGColor();
            Layer.BackgroundColor = Color.Transparent.ToCGColor();
        }

        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            AddDashedBorderFrame();
        }

        private void AddDashedBorderFrame()
        {
            dashedBorderFrame.StrokeColor = Element.BorderColor.ToCGColor();
            dashedBorderFrame.FillColor = null;
            dashedBorderFrame.LineDashPattern = new NSNumber[] { new NSNumber(6), new NSNumber(6) };
            dashedBorderFrame.Frame = NativeView.Bounds;
            dashedBorderFrame.Path = UIBezierPath.FromRect(NativeView.Bounds).CGPath;
            Layer.AddSublayer(dashedBorderFrame);
            Layer.BorderColor = Color.Transparent.ToCGColor();
            Layer.BackgroundColor = Color.Transparent.ToCGColor();
            Element.HasShadow = false;
        }
    }

Expected Behavior

Screenshot 2020-07-22 at 09 28 10

Actual Behavior

Screenshot 2020-07-22 at 09 24 03

Basic Information

  • Version with issue: 4.6.0.1141
  • Last known good version: 4.6.0.800
  • IDE: VS for Mac
  • Platform Target Frameworks:
    • iOS: 13.5
  • Nuget Packages: Xamarin.Forms (latest versions)
  • Affected Devices: iOS

Screenshots

Reproduction Link

Workaround

felipemomm avatar Jul 22 '20 07:07 felipemomm

@felipemomm Please try 4.6.0.1180 and let us know if that resolves the issue. Thanks!

samhouts avatar Jul 22 '20 23:07 samhouts

@samhouts Unfortunately the issue is still happening on 4.6.0.1180 and in the latest 4.7.0.1179 as well.

felipemomm avatar Jul 23 '20 11:07 felipemomm

@samhouts Can you re-open this issue?

felipemomm avatar Jul 27 '20 13:07 felipemomm