Problem with UIBezierPath and CGPath
Not sure whether this is directly Pythonista-related, but I'm having some trouble with
objc_util. Code that appears to work elsewhere fails in Pythonista, and I don't think I'm doing anything obviously wrong.
I'm trying to implement a progress bar that strokes along a
ui.Path. I think I need to have a
CAShapeLayer, then animate the
strokeEndproperty, and somehow do all this inside
But, no matter what I do, I can't get a
The first thing I tried was this:
import ui from objc_util import * a = ui.Path() a.line_to(10, 0) a.line_to(10, 10) a.close() b = ObjCInstance(a) print(b.CGPath())
I always get a
c_void_pfrom this. I even get similar results from
from objc_util import * print(UIBezierPath.new().CGPath())
What's going on here?
CGPath is an opaque type, basically a pointer to an object we cannot interpret directly.
As a more general comment, when you get back c_void_p's, often you can use ObjCInstance on the pointer to get the bridged object.
>>> ObjCInstance(ObjCInstance(p).CGPath()) <b'__NSCFType': <CGPath 0x1695a830>>
In this case, since CGPath is opaque, there is not much you do with a CGPath itself. You pass CGPaths to C functions, it does not have methods like an object per se.