I am trying to get an animated image in a canvas to animate, but I don't believe that sprite rendering works with canvas'. Ive tried adding an animation component to it however I need the image to have the controller on it, as it's animation changes all the time. How would I be able make the UIImage animated whilst still using the Animation controller
You need to create an animation using Animation View and selected UIImage - Animation View will let you change UIImage sprites, position and more.
Then simply drop that animation into your Animation Controller and create whatever transitions you want.
Here you can read more about it:
Animation View Documentation
Related
I'm currently flipping a UIImageView using UIView transitionWithView: duration: options: animations: completion: and switching the image inside the animation block. One of the two images it's switching between is landscape and the other is portrait so its also rotating and resizing the imageview so they both fill the screen.
What I can't figure out is how to animate the flip, and rotate it at the appropriate time but not animate the rotation. Is there a way to do this?
You might also try putting the change you don't want to be animated inside a CATransaction begin/commit, with setDisableActions:TRUE. (inside your animation block.) I don't know if it would work or not, but it would be worth a try.
Well, I am looking for a way to change my spinner image and use a custom image
Any suggestion?
I have created a subclass of UIActivityIndicatorView that allows you to set a custom image.
You could simply use a UIImageView and add an animation that rotates the view's layer indefinitely. You can achieve this using CoreAnimation. There are plenty of tutorials for this out there.
If you wish to start and stop the animation you can create a simple subclass of UIImageView that adds and removes said animation.
Here's a link for the animation: Basic keyframe animation (rotation)
Is it possible do something like this ?
When I click on the button I need the following animation: button to set some alpha filter and starts to fall down as indicated by the arrow, it will disappear on tab.
Can you tell me how to do this ? Thanks a lot ...
Here is image url: http://img534.imageshack.us/img534/8149/screenqx.jpg
It's definitely possible, but there are some issues you have to overcome. One is that UIBarButtonItem isn't a UIView. One way is to loop through the subviews of the UIToolbar or UINavigationBar. Another way is to figure out the position of the button. Another is to get the view using private api if you're not submitting to the AppStore.
Once you have the view, you can move it to the superview of the UIToolbar or UINavigationBar or you can create a view on top of that (and hide the real UIBarButtonItem since you're done with that). The latter is more difficult because mimicking the look of the default bordered UIBarButtonItem isn't easy.
Now you need to get the center of the UITabBarItem somehow. You can either use private api or you can loop through the subviews.
Create a CGPath using Quartz functions or using UIBezierPath. The start point will be the center of the button and the end point will be the center of the UITabBarItem.
Create a CAKeyFrameAnimation and attach said CGPath.
Create a CABasicAnimation to animate the opacity.
Add both to a CAAnimationGroup.
Attach the animation group to your button view's CALayer.
Make sure to also set the position and the alpha in order to prevent the view from jumping back to its original position after the animation.
Once you attach the animation group, the animation should start, so make sure you're doing all of this in the button's selector method.
You can't really move it from view to view, as your views could clip and then you'd get frames with only a partial image. Probably the best thing to do is to create a view on the fly which covers the whole screen, copy the button image into the view at the original point, remove the button from the original view, then animate that image to where you want it to go, then add the button to the final destination.
I have an UIImageView which I can rotate using CABasicAnimation. That works fine. Now I wanted to add a fixed background view, which should stay unchanged and shall not follow the rotation (think of a radar device with fixed target echos).
I have added my bg as subview to the UIImageView, but unfortunately (but not unexpectedly) the whole image rotates, not only the foreground, if I rotate the layer of my UIImageView.
Is there a way to have a fixed background layer and a rotating layer on top? Even if I add my background as layer to the UIImageView layer the whole thing rotates...
Regards
You can simply rearrange your layout so that you have a superview that contains both your background and the UIImageView that needs rotating—something like this:
Container View
Background View
UIImageView
That way, you can rotate the UIImageView at will without affecting the background.
Of course, the container view is only useful if you eventually need to manipulate both the background and the image view together, at which point you can simply animate the container, thus affecting both.
If you rotate parent view then all subview will also rotate. For this you don't need to make background and foreground subview of one another. Add the background to a parent view, then add foreground to the same parent view, that is foreground is not child of background. Then apply rotation only on the foreground (not on the parent view). This should not affect the background or other child of the parent.
I have an animation I'm using to snap a rotatable UIView to a circular grid. As the view animates, I need to update another view based on the rotating views position.
How can I go about getting the position of the rotating view as it animates into position?
When animation starts you can start a function that will be polling current view position using a timer (I suppose you will need to get presentationLayer from view's layer and get position values from it).
There's no callbacks for CAAnimation other than animationDidStart and animationDidStop so it seems that's the solution (if I'm not mistaken it was also mentioned so in one of WWDC videos).