예제 #1
0
 public static void ApplyCornerRadius(UIView currentView, UIRectCorner radiusCorners, bool remove = false, int radius = 4)
 {
     if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
     {
         currentView.Layer.MaskedCorners = radiusCorners.ToCornerMask();
         currentView.Layer.CornerRadius  = radius;
     }
     else
     {
         UIBezierPath maskPath  = UIBezierPath.FromRoundedRect(currentView.Bounds, radiusCorners, remove ? new CGSize(0, 0) : new CGSize(radius, radius));
         CAShapeLayer maskLayer = new CAShapeLayer();
         maskLayer.Frame        = currentView.Bounds;
         maskLayer.Path         = maskPath.CGPath;
         currentView.Layer.Mask = maskLayer;
     }
 }
예제 #2
0
        public static void ApplyBorder(this UIView currentView, UIRectCorner radiusCorners, int radius = 0, UIColor color = null, float lineWidth = 1f)
        {
            var col = color == null?UIColor.FromRGB(61, 71, 82).CGColor : color.CGColor;

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                currentView.Layer.MaskedCorners = radiusCorners.ToCornerMask();
                currentView.Layer.CornerRadius  = radius;
                currentView.Layer.BorderWidth   = lineWidth;
                currentView.Layer.BorderColor   = col;
            }
            else
            {
                UIBezierPath maskPath = UIBezierPath.FromRoundedRect(currentView.Bounds, radiusCorners, new CGSize(radius, radius));
                ApplyBorder(maskPath, currentView, col, lineWidth);
            }
        }