我想绘制消息单元格(见附图)。它应该有颜色填充和外部边界概述。问题在于它显示了我不需要的内部边界。 代码:
public static UIBezierPath CreateMessageBubble (CGRect frame, float cornerRaduis, float quoteBubbleLength, bool leftSide)
{
//var shape = CreateMessageBubbleWithQuote (frame, cornerRaduis, quoteBubbleLength, leftSide);
//return shape;
bool left = leftSide;
UIBezierPath roundedPath = UIBezierPath.FromRoundedRect (
new CGRect (frame.X + (left ? quoteBubbleLength : 0), frame.Y, frame.Width - quoteBubbleLength, frame.Height),
UIRectCorner.AllCorners,
new CGSize (cornerRaduis, cornerRaduis)
);
roundedPath.UsesEvenOddFillRule = false;
if (left) {
roundedPath.MoveTo (new CGPoint (quoteBubbleLength + cornerRaduis, frame.Height - cornerRaduis));
roundedPath.AddCurveToPoint (
new CGPoint (0, frame.Height),
new CGPoint (quoteBubbleLength + cornerRaduis * 0.25f, frame.Height),
new CGPoint (0, frame.Height)
);
roundedPath.AddCurveToPoint (
new CGPoint (quoteBubbleLength, frame.Height - cornerRaduis),
new CGPoint (0, frame.Height),
new CGPoint (quoteBubbleLength, frame.Height - cornerRaduis * 0.5f)
);
} else {
roundedPath.MoveTo (new CGPoint (frame.Width - quoteBubbleLength, frame.Height - cornerRaduis));
roundedPath.AddCurveToPoint (
new CGPoint (frame.Width, frame.Height),
new CGPoint (frame.Width - quoteBubbleLength, frame.Height - cornerRaduis * 0.5f),
new CGPoint (frame.Width, frame.Height)
);
roundedPath.AddCurveToPoint (
new CGPoint (frame.Width - (quoteBubbleLength + cornerRaduis), frame.Height - cornerRaduis),
new CGPoint (frame.Width, frame.Height),
new CGPoint (frame.Width - (quoteBubbleLength + cornerRaduis * 0.25f), frame.Height)
);
}
roundedPath.ClosePath ();
roundedPath.AddClip ();
return roundedPath;
}
填写和设置笔划的代码:
using (CGContext gctx = UIGraphics.GetCurrentContext ()) {
var shape = BlrtiOS.Util.BlrtUtilities.CreateMessageBubble (Bounds, CornerRadius, AligmentPadding, _alignmentLeft);
gctx.SetFillColor (_bubbleColor.CGColor);
gctx.SetStrokeColor (BlrtStyles.iOS.Green.CGColor);
gctx.SetLineWidth (1);
gctx.AddPath (shape.CGPath);
gctx.DrawPath (CGPathDrawingMode.FillStroke);
}
所需:
当前: