2

Is there an equivalent function available in Xamarin.iOS for CGPointFromString

I looked at online Xamarin API documents and nothing that I found relevant.

Renish
  • 76
  • 8

1 Answers1

0

There is not any built in method for equivalent to CGPointFromString in Xamarin.iOS. You can use following to get CGPoint from string.

        String str = "{23,213}";
        str = str.Replace('{', '');
        str = str.Replace('}', '');

        string[] coord = str.Split(',');
        CoreGraphics.CGPoint pt = new CoreGraphics.CGPoint(Int64.Parse(coord[0]), Int64.Parse(coord[1]);
PlusInfosys
  • 3,416
  • 1
  • 19
  • 33
  • 1
    I ended up doing something like this....`List points = new List(); for (int index = 0; index < pts.Length; index++) { CGPoint p = new CGPoint(); p.X = Convert.ToSingle(pts[index].Split(',')[0]); p.Y = Convert.ToSingle(pts[index].Split(',')[1]); points.Add(p); }` where pts is an Array with values like `"[x1,y1],[x2,y2],[x3,y3],....[xn,yn]"` – Renish Dec 02 '16 at 04:32