Access interim points while UIView is animated - iphone

I'm animating an image in an UIImageView. This works just great with Core Animation. Now I want to attach one end of a line permanentely to the center of this UIIMageView. But with Core Animation I only get the starting point and the end point of the UIImageView. Is there a possibility to access interim points during the animation? I want to extend the functionality to many UIImageViews, which are animated, with a line attached to them. I don't want to create timers to monitor all animations and calculate my own interim points. Does somebody have any suggestions? Thanks!
Bye, Björn

If you're using Core Animation (I'm not sure if this works with strictly UIView-based animation), you should be able to get a particular instantaneous value of your property by looking at the presentationLayer property of your view's backing CALayer. That property exposes a read-only copy of the current set of values as a layer is animating. You can look at this on a display link "timer" and update something else, etc.
I'm having a tough time picturing exactly what you're trying to accomplish overall, but this might get you started.

I found this post, which points to the right direction: http://dbachrach.com/blog/2008/04/instantaneous-frame-of-moving-core-animation-views/
But there's still one problem: this seems to work for CABasicAnimations only, not for the standard animations. Is there a way to access interim points when using standard animations ([UIView beginAnimation] ...)?? Thanks.
Björn

Related

OpenGL ES : Revealing underneath view

I am working on a sample in which I have placed two textures one above the other. What I want, whenever user moves his finger on the screen, underneath view should get revealed as he moves. Wiping out front view to reveal underneath view is what I am looking for.
I would like to know some of ideas/ thoughts to implement this feature using OpenGL ES. Any related pointer will be highly appreciated.
Thanks in advance.
This does not sound performance-intensive so simple code can trump complicated tuned operations.
You don't need to use OpenGL. You can simply have two images - front and back - with the front supporting an alpha channel. Each time you get a hit or move, you clear a circular patch whereever the impact is for some certain radius or such.
And then queue-up a redraw. The redraw draws the two bitmaps, back first then front.
If possible, try to queue a redraw for just the the area where you have updated the front since the last draw.

Creating a 360 degrees image turntable viewcontroller?

I want to create a 360 degree turntable showing lots of pictures (12, 24 or 36) by controlling that rotation with touch events (like that example but coded for an iOS app natively).
The simplest idea depending on the touch position is to load that specific uiimage.
Any ideas what's the best practice for that? Is there a chance to create that image-turntable with the help of coreanimation faster? Any other hints on that? Any other projects known where I can get some help on that?
Thanks for your time and hints in the right direction.
Here's another example for an ipad-app from the "audi a8".
From the first example it becomes obvious that the objects have actually been photographed for each angle of rotation. This is the really tricky part. You will need a tripod and a camera with remote control, and if possible also a rotational platter to keep angles consistent.
Implementation is relatively straightforward. As you guessed, you just track the touch positions and, depending on delta to the last touch position, show the appropriate image.
well, you can just use the HTML/CSS/JS used in the same example... just load that in an UIWebView in your app and load your site embedded as a resource...
Subclass UIImageView, load array of your frames, handle tap movement over the screen y-axis and change active image accordingly. Don't forget to loop your images. :)

Animate a GIF using Core Animation layers?

I'm trying to animate a GIF and I hit a roadblock. I have an example of what I'm trying to do that uses the individual frames of the GIF and setting the animationImages property of a UIView. However in my project, the thing I want to animate is drawn using Layers. I'm looking for a quick and easy way to animate the frames without introducing too much complexity. Is there any animationImages equivalent with Layers? Does anybody have any ideas?
Another solution:
The contents property of a CALayer is animatable. Meaning you can create a CAKeyFrameAnimation and supply it with an array of images for each frame. You can also set the timing of it.
Note, will likely work better with PNGs
Maybe that helps instead.
Here you go, enjoy:
http://github.com/jamesu/glgif

How to implement slurp effect on iPhone?

The iPhone has a private list of effects that Apple uses, such as "genieEffect" and "slurpEffect". I'm wondering how one would go about implementing the slurp effect (this is when you trash a mail message or a note).
I understand how to use Core Animation, but I'm not sure exactly what parts of it they're using to get that animation.
This post talks about using the private API for the effect:
link text
It seems to be a complex combination of 2D and 3D transformations. :-\ You'd have to really delve into CoreAnimation to simulate this effect.
I would do it with an affine transformation applied to the view's layer. Linear algebra is not my strong point ;) so I can't specify the exact transformation but my guess would be something like this for the animation:
Set the alpha to fade to 0.0 or
something close to 0
Apply a transform to squish the two bottom corners close to the center
Scale down the view to very small
move the layer's center down to the bottom of the screen (or wherever you want it to genie to.
That's more or less how I think it would work. You might have to animate these things at different times, or all in one block, I'm not quite sure.
Have a look at documentation for CALayer, CABasicAnimation, and CGAffineTransform.

Moving a UIView along a CGPath according to touch position

I have a line graph I've drawn in Quartz, and a UIView 'bubble' that I'd like to ideally pop up when the user touches the single plot line, and moves their finger along it. The bubble displays some extra graph information.
I'd like to 'attach' the UIView to the CGPath plot, but I'm having trouble conceptually figuring out the best way to do this. I know you can animate a view along a CGPath, but this doesn't seem to work for me, because the user needs to 'scrub' along the graph themselves with their finger rather than any automatic animation.
Does anyone have any suggestions of a good approach?
Maybe you don't need to animate it. Touch events fly by pretty quickly -- maybe if you just move the view to the appropriate location relative to the touch without animation the move will be smooth enough. If that's not good enough, you'll have to animate along the graph segment from the current location of the view (see CALayer presentationLayer) to the desired location. The key is that you'll be animating every time you receive a touch event (and any previous animations would be cancelled).
Like Neil said, your best bet is to just move with the touch events, it will look smooth if all you're doing is moving a view. Use [aTouch locationInView:view] to get the touch's position, then find the closest point on the path (maybe use the x value and look up the y value on the path for the x).