Xamarin中的CGMutablePath

时间:2017-11-21 15:17:41

标签: swift xamarin xamarin.ios

我正在尝试为我的Xamarin.iOS应用翻译此代码:

https://github.com/yourtion/YXWaveView/blob/master/YXWaveView/YXWaveView.swift

第179行:

let path = CGMutablePath()

我在Xamarin中找不到CGMutablePath

2 个答案:

答案 0 :(得分:2)

ObjC CGMutablePathRef struct(或Swift CGMutablePath类)被Xamarin.iOS包装为CGPathCoreGraphics命名空间)。

var path = new CGPath();

xamarin-macios / SRC / CoreGraphics中/ CGPath.cs

public class CGPath : INativeObject, IDisposable {
        internal IntPtr handle;

        [DllImport (Constants.CoreGraphicsLibrary)]
        extern static /* CGMutablePathRef */ IntPtr CGPathCreateMutable ();

        public CGPath ()
        {
            handle = CGPathCreateMutable ();
        }

        [Mac(10,7)][iOS (5,0)]
        public CGPath (CGPath reference, CGAffineTransform transform)
        {
            if (reference == null)
                throw new ArgumentNullException ("reference");
            handle = CGPathCreateMutableCopyByTransformingPath (reference.Handle, ref transform);
        }

        [DllImport (Constants.CoreGraphicsLibrary)]
        extern static /* CGMutablePathRef */ IntPtr CGPathCreateMutableCopy (/* CGPathRef */ IntPtr path);

        public CGPath (CGPath basePath)
        {
            if (basePath == null)
                throw new ArgumentNullException ("basePath");
            handle = CGPathCreateMutableCopy (basePath.handle);
        }
 ~~~~~

答案 1 :(得分:1)

您可以使用:

var path = new CGPath();