Drake
Drake

Reputation: 2713

CGMutablePath in Xamarin

I am trying to translate this code for my Xamarin.iOS app:

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

On line 179:

let path = CGMutablePath()

I can't find CGMutablePath in Xamarin?

Upvotes: 4

Views: 490

Answers (2)

SushiHangover
SushiHangover

Reputation: 74209

An ObjC CGMutablePathRef struct (or Swift CGMutablePath class) is wrapped by Xamarin.iOS as a CGPath (CoreGraphics namespace).

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);
        }
 ~~~~~

Upvotes: 4

Umair M
Umair M

Reputation: 10750

You can use this:

var path = new CGPath();

Upvotes: 2

Related Questions