I'm about to start work on my first big iOS app, but haven't really started any code yet... So it's all theoretical, and in my head at the moment as I'm still in the design phase.
Regardless, I know I'm going to need some animation effects in the app, so I'm just doing some research. In Flash (AS3), there are libraries like Tweener, and TweenLite that have TONS of easing options available.
Am I crazy, or are there really no other easing options available besides the four standard ones:
UIViewAnimationCurveEaseIn
UIViewAnimationCurveEaseOut
UIViewAnimationCurveEaseInOut
UIViewAnimationCurveEaseOut
Am I really going to have to dig into deep core animation to accomplish this? Or does anyone know of some 3rd party SDK that'll come in handy.
Thanks all...
Actually, there is one other: UIViewAnimationCurveLinear... Wow, that's a downer. The reason you're seeing such limited options, is because you've only explored UIView's Core Animation wrapper. Core Animation is much more powerful, and capable than that. If you need absolute fine-grain control over your animation, use CAKeyFrameAnimations, and if you need soft-grain control, use CAAnimation and CABasicAnimation. Even CATransaction will work. Basic easing curves were built into iOS because you are expected to provide the instructions for interactions more complicated than that. See here for an excellent series of easing curves that work great with CAKeyframeAnimation. Of course, this isn't for everyone... So there's a beta framework available with built-in tweeting values here
As the other poster suggested, keyframe animations let you describe motion along complex curves, or between designated key points.
If you want a custom timing function, you can create one pretty simply, and use it anywhere that you can specify one of the canned timing functions like linear or ease in, ease out. Take a look at the CAMediaTiming Function class reference. Specifically, look at the method functionWithControlPoints::::
That lets you create a timing curve using a single cubic bezier curve. That's your only option, I'm afraid.
What effect are you after, specifically?
Related
Creating Perfectly "up to spec" Animations
I'm working with a designer right now that likes to work a lot with After Effects. They create beautiful, well timed animations that look great, but I'm having trouble actually implementing the designs.
I can make everything look perfect, as in everything is the right size, shape, color, etc., but I can't get the movements to feel perfect, like they are in the spec. I can try my best to eyeball it, and tweak my animation parameters until things look close enough to the original design, but this isn't very satisfying. All of that tweaking and recompiling is super time consuming, and not very fun, and in the end things don't always feel correct as I can only approximate the timing functions.
Are there any tools that make implementing After Effects animations in iOS easier?
I would suggest that you take a look at my animation library for iOS. iOS Animation Examples With this native library you can import Quicktime video data using the Animation codec and convert that data with exact timing already defined by the animators. This ability to export directly from After Effects can really save you a lot of time.
inspired by the the animated graph from Joe Ski on his dribbles profile I wonder where to start if I want to implement something like this on iOS.
Is CoreGraphics and drawRect combined with NSTimer the right starting point? Where comes CoreAnimation into the game? Or is CorePlot the platform to build on?
Can you please advice me where I have to dig into?
You need to start by exploring the Core Animation framework and have some knowledge about Core Graphics. This is how I would go about it:
Define your shapes with UIBezierPaths
Define the target shapes with different paths
Animate the "path" key with CABasicAnimation between the start and target paths
Happy exploring!
Generally, if you'd like to implement an advanced custom animation, I think you should start with CADisplayLink (and CVDisplayLink for MacOS).
CADisplayLink allows you to intervene every single time the screen is refreshed, e.g: ~60 times/second if you are having 60fps.
If you look at its examples, you'll see that it also gives you timing information so that you don't need to rely on NSTimer which doesn't go well with animations actually.
In you particular case, as Mundi said, CABasicAnimation might be enough as well.
Also, you can follow BAFluidView example on Github which uses CAKeyframeAnimation to achieve something similar.
I need to add typical finger drawing to an app.
(The usual.... choose colors, erase, thickness - just the usual you see in every app made.)
It's hard to believe I have to program this from scratch, in this day and age?
It's hard to believe there is not a common solution for this?
All I could find is...
https://github.com/levinunnink/Smooth-Line-View
Review: that is a (beautifully written) example fragment of a few lines of code being how to draw with a path, with a good smooth result. It works perfectly, but it's just for drawing one "path." For example, you can't make a drawing with more than one color. there is no undo or anything like that. (See also note on the fourth review item here regarding path-math.)
https://github.com/sumanthk2006/Smooth-Line-View-1 (variation of above, but does not run under ARC, unfortunately demo does not properly launch etc)
Review: this is "abandonedware" or maybe "frustrationware" :) It does not run and is not ARC-ready. It is a seemingly well-written class that claims to do undo, colors, erase, etc. It even has a proper delegate to track your button states. But it doesn't work.
UPDATE Regarding this paackage. As a matter of fact, if you massage it it works well. Suggest (i) throw away the example app files. (ii) using modern Xcode, use the "convert to ARC project" feature on the two main files. There are a coupe little problems like it should use awakeFromNib. If you get it working it actually does everything, really well.
THERE ARE SERIOUS BUGS in SmoothLineView1. just to be clear, it suffers some serious bugs - you'll see there's a "streaking" effect when you draw.
http://www.cdframeworks.com/product/brushengine
Review: This commercial package (under $100) is well made and email support is fast. Unfortunately it does not have undo so it's not suitable for many situations. (Also does not have erase.)
Mentioned below is this popular article:
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_freehand-drawing/
Review: this is a good article on the actual TECHNOLOGY of drawing curves, on the let's say "path-math". Unfortunately it's no help at all if you need a working, ready to use, drawing package (with the obvious features, undo, erase, colors etc) to use in an iOS app. Thus for example, whatever actual solution you were using, you may, perhaps, want to apply the math concepts in this article.
I appreciate that the basic concepts are very simple, it's easy enough to "start from scratch". But it's just - ridiculous - to have to do from scratch for something so commonplace. Is there a solid package I'm missing?
It's fairly amazing that the four scratchy references above are the only things out there.
Any ideas? What's the best package today (late 2013) for adding drawing to an iOS app? THANKS.
As of 2017, I use https://github.com/acerbetti/ACEDrawingView/.
It can be used through cocoa pods, and provide full functionality over integrating a drawing feature in your app (color, brush, size, eraser, undo/redo/, etc).
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_freehand-drawing/ has a good, clear tutorial on smooth freehand drawing on the ios. If you just follow the tutorial, you can implement it easily into whatever app you are trying to make. It has stuff about increasing line quality and smoothness, and stroke quality.http://www.raywenderlich.com/18840/ is another tutorial on a simple drawing app, self-contained. You can combine aspects of both to get what you want.
edit: https://developer.apple.com/library/ios/samplecode/GLPaint/Introduction/Intro.html is the GLPaint sample provided by apple, which includes detecting shake. I thought it seemed more official, since it's from apple
to answer your question, there is no package for drawing directly, but there is a UIKit class, UIBezierPath, that lets you draw shapes made of straight lines or some curves.
I would like to achieve a cool particle effect like in here.
The bubble should be similar to an explosion starting from the centre and expanding. I'd like to add an animated wave coming out from the left and right side of the bubble and looking like this. I guess I could use to two distinct animation and put together as I assume this has never been done in a Cocos2d game.
Also, I would like to avoid using non-Cocos2d tools as particle designer. In chapter 1 of the Cocos2d cookbook I found some cool particle examples and the code doesn't seem too complex. Instead, using third party tools I need to import their classes and use their file format to create particles and I have to pay. Even more there doesn't seem to be many particle effect files shared (at least not the ones I want).
Thanks a lot.
EDIT: I added a comment with a theory on how the first of the two animation could work.
Your best chance is with Particle Designer. You can modify the emitters in the library and visualize your changes. It's the easiest way to achieve a great effect. Once you find the combination of values that you like , you can simply create an emitter from code and set all those properties yourself. You don't have to pay or use any class (which you actually don't have to , it's already built in cocos2D) . So just download the free version of Particle Designer and then set the values from code. It's the same thing , it only takes a bit more work to do.
I want to draw a sinusodial wave which varies with time on a UIView.
What are the approaches should i take ?
Any sample code is there ??
I believe the easiest way I've heard of doing what you want to do is using CAKeyframeAnimation.
There is a tutorial page with a sample project here:
http://cocoawithlove.com/2008/09/parametric-acceleration-curves-in-core.html
There is a stackoverflow about something similar here:
Basic keyframe animation (rotation)
and the Apple Developer Documentation lists an example application called "MoveMe" that uses keyframe animations
I do not think you have to go all the way to OpenGL for this, but it is certainly capable of this.