sync drawing an ever-increasing path
sync drawing an ever-increasing path
- Subject: sync drawing an ever-increasing path
- From: Roland King <email@hidden>
- Date: Tue, 23 Oct 2012 19:37:12 +0800
I want to animate the drawing of CGPath in a UIView, so it looks as if it's being drawn. I have the UIView, I have the CGPath, I am able to split the CGPath at any point from 0 to 100% into that which should be drawn and that which shouldn't yet, that's all done, so I can, fairly efficiently, call -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a path.
The idea is to call setNeedsDisplay on the UIView from time to time, then figure out, when I get my -drawRect call how far through the animation I am, call fractionalPath: for that fraction of the total animation time, and draw it. The path isn't that complex, it doesn't take very long to draw and I'm compositing already-fully-drawn paths into a backing UIImage so there's only one 'live one' at any time.
The bit I'm not sure about is how to sync this up with the natural framerate of the device. I could call setNeedsDisplay on a timer, or with a delay after each drawRect, but there is surely a better way to do this, is there not? If I do call setNeedsDisplay a lot, will I only get drawRect at most at the natural framerate of the device.
Is there an obvious technology I'm missing? This is a pretty simple way to do a quick animation of a single path, so OpenGL or anything like that is massive overkill and I didn't see anything CALayer would give me which would help, but wondered if I'd missed something there as that does have the concept of animating a property, even a custom one, between two values and I wondered if I could hook into that.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden