コード例 #1
0
        private UIRectCorner GetCornerPosition(UIRectCorner corner, bool shouldAppend)
        {
            var val = corner;

            if (RoundedCornerEffect.HasTopLeft(this.Element))
            {
                val = shouldAppend ? val | UIRectCorner.TopLeft : UIRectCorner.TopLeft;
            }

            if (RoundedCornerEffect.HasTopRight(this.Element))
            {
                val = shouldAppend ? val | UIRectCorner.TopRight : UIRectCorner.TopRight;
            }

            if (RoundedCornerEffect.HasBottomLeft(this.Element))
            {
                val = shouldAppend ? val | UIRectCorner.BottomLeft : UIRectCorner.BottomLeft;
            }

            if (RoundedCornerEffect.HasBottomRight(this.Element))
            {
                val = shouldAppend ? val | UIRectCorner.BottomRight : UIRectCorner.BottomRight;
            }

            return(val);
        }
コード例 #2
0
        private void UpdateBorderLayer(UIBezierPath maskPath)
        {
            var borderWidth = RoundedCornerEffect.GetBorderWidth(this.Element);
            var borderColor = RoundedCornerEffect.GetBorderColor(this.Element);
            var bounds      = new CGRect(0, 0, FormView.Width, FormView.Height);

            _borderLayer?.RemoveFromSuperLayer();
            _borderLayer = new CAShapeLayer
            {
                FillColor   = Color.Transparent.ToCGColor(),
                StrokeColor = borderColor.ToCGColor(),
                LineWidth   = (nfloat)borderWidth,
                Frame       = bounds,
                Path        = maskPath.CGPath
            };
            SetLayer(NativeView, _borderLayer);
        }
コード例 #3
0
        private void UpdateLayer()
        {
            var position = RoundedCornerEffect.GetRoundedCornerPosition(this.Element);
            var radius   = RoundedCornerEffect.GetRadius(this.Element);

            if (position == RoundedCornerPosition.None)
            {
                return;
            }
            var bounds = new CGRect(0, 0, FormView.Width, FormView.Height);

            var corner = GetCornerPosition(UIRectCorner.AllCorners, false);

            corner = position == RoundedCornerPosition.AllCorners ? UIRectCorner.AllCorners : GetCornerPosition(corner, true);

            var maskPath = UIBezierPath.FromRoundedRect(bounds, corner, new CGSize(radius, radius));

            UpdateMaskLayer(maskPath);
            UpdateBorderLayer(maskPath);
        }