Re: How to redraw a view in slow-motion
Re: How to redraw a view in slow-motion
- Subject: Re: How to redraw a view in slow-motion
- From: Ken Tozier <email@hidden>
- Date: Sun, 19 Jun 2011 10:37:03 -0400
If you keep the animation short (say 1.5 to 2 seconds) the freezes might not be too irksome to the user, but eliminating them altogether would require adding NSOperationQueues and NSInvocationOperations to the mix and this is even too hokey for me :)
With CALayers, you could create 10 different layers each with a different subset of lines right in your setFrame method (or whichever methods cause the drawRect to trigger) Then with those animation frames in hand you could set up an animator to composite a new layer at some appropriate interval. As I said, I'm very new to CALayers myself, so I don't know exactly how to do this, but the complexity (and uglyness) of the roll-your-own solution makes CALayer look like an attractive option.
-
On Jun 19, 2011, at 9:57 AM, Matthias Arndt wrote:
> Hi Ken,
>
> Am 19.06.2011 um 15:40 schrieb Ken Tozier:
>
>> - (void)observeValueForKeyPath:(NSString *) inKeyPath
>> ofObject:(id) inObject
>> change:(NSDictionary *) inChange
>> context:(void *) inContext
>> {
>> if ([inKeyPath isEqualToString: @"subsetRange"])
>> {
>> // figure out how many lines you still have to draw here
>> if (stillHaveLinesToDraw == YES)
>> {
>> sleep(<some number of ticks>);
>> [self setNeedsDisplay: YES];
>> }
>> }
>> }
>
> Thanks for this speedy reply! Using a KVO observer is a new approach I haven't considered, yet. But the main difference to my first idea is the usage of repetitive invocations of "drawRect:" instead a loop inside the method itself. To make this a slow-motion, you mentioned a "sleep(...)" (wasn't included in the mailing list reply), which will freeze the GUI, won't it?
>
> CAAnimation sounds promising, unfortunately I haven't used it before, and animating several paths doesn't seem to be covered with basic animations ... I'd look deeper into the references, but currently I'm afraid it's beyond my capabilities.
>
> Matthias
_______________________________________________
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