xamarin.ios - 如何在Xamarin中画一条直线?

标签 xamarin.ios xamarin-studio

如何使用 C# 在 Xamarin 中的 imageview 上绘制直线。我必须画直线并计算该线的长度。 请帮我。提前致谢..

最佳答案

您可以扩展 UIImageView 并在方法内画一条线,如下所示:

public void DrawLine()
{
    CGContext context = UIGraphics.GetCurrentContext ();
    context.SetLineWidth (4);
    UIColor.Clear.SetFill ();
    UIColor.Black.SetStroke ();
    currentPath = new CGPath ();
    currentPath.AddLines (points.ToArray());
    context.AddPath (currentPath);    
    context.DrawPath (CGPathDrawingMode.Stroke);   
    context.SaveState ();
}

points 是 PointF 对象的列表。

关于xamarin.ios - 如何在Xamarin中画一条直线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17444681/

相关文章:

ios - 可变高度 UITableViewCell 在滚动到列表末尾并旋转后展开

ios - 使用 Monotouch 修剪视频失败并显示 "The operation could not be completed"

xamarin - 如何拦截在 Xamarin 表单中单击的导航栏后退按钮?

ios - Xamarin Studio 上的 iOS Designer 中感叹号的含义

xamarin - System.TypeLoadException : 'VTable setup of type Xamarin.Forms.Forms+AndroidPlatformServices failed'

iphone - 异步更新数据后重绘 UITableView

ios5 - 推送通知使用的 monotouch Iphone 唯一标识符或 MAC 地址

c# - 使用 LINQ 查询 Azure MobileServiceSyncTable

c# - 在 Mac OS X 上的 Xamarin Studio 6.1 中使用 System.Security.Cryptography 时出现程序集引用错误 (CS0234)

ios - 中心 ScrollView 对象到每个水平滚动页面 - Xamarin iOS