C# Xamarin iOS UIBezierPath将方向更改为底部
我想在图像上画一条路径,它表示Xamarin中的半进度条。然后它适用于顶部 但现在我想画底部。但是我试了又试,没有找到任何东西 这张图片会解释你。 守则:C# Xamarin iOS UIBezierPath将方向更改为底部,c#,ios,xamarin,mask,layer,C#,Ios,Xamarin,Mask,Layer,我想在图像上画一条路径,它表示Xamarin中的半进度条。然后它适用于顶部 但现在我想画底部。但是我试了又试,没有找到任何东西 这张图片会解释你。 守则: public CircleGraph(UIImageView imageView, int lineWidth, float percentComplete) : base(imageView.Frame) { Initialise(imageView, lineWidth, percentComplete); } void In
public CircleGraph(UIImageView imageView, int lineWidth, float percentComplete) : base(imageView.Frame)
{
Initialise(imageView, lineWidth, percentComplete);
}
void Initialise(UIImageView imageView, int lineWidth, float percentComplete)
{
_lineWidth = lineWidth;
_percentComplete = percentComplete;
this.BackgroundColor = UIColor.Clear;
this.backgroundImage = imageView;
Add(backgroundImage);
centerPoint = new CGPoint(Bounds.GetMidX(), Bounds.Height);
maskLayer = new CAShapeLayer();
maskLayer.FillColor = UIColor.Blue.CGColor;
maskLayer.StrokeColor = UIColor.Black.ColorWithAlpha(.5f).CGColor;
maskLayer.LineWidth = _lineWidth;
maskLayer.LineCap = CAShapeLayer.CapButt;
this.Layer.Mask = maskLayer;
}
public void SetClipping(float percentComplete) {
_percentComplete = percentComplete;
SetNeedsDisplay();
}
public override void Draw(CoreGraphics.CGRect rect)
{
base.Draw(rect);
using (CGContext g = UIGraphics.GetCurrentContext())
{
_radius = (int)(this.Bounds.Width / 2) - _lineWidth / 2;
// Top
var startAngle = -(float)Math.PI;
var endAngle = startAngle + HALF_CIRCLE * _percentComplete;
maskPath = new UIBezierPath();
maskPath.AddArc(centerPoint, _radius, startAngle, endAngle, false);
maskLayer.Path = maskPath.CGPath;
};
}
非常感谢 我找到了
只需将你的高度中心点设置为0,然后使用startAngle、endAngle和顺时针进行游戏,就可以了