Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I believe you want to animate the heights of the bars in the bargraph. I suggest you implement each bar as a separate UIview, a simple rectangle. You can also put all of them in one view with a custom drawRect. Then you need to scale these views or change their frame inside the animation block of either of the following methods:</p> <pre><code>+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion </code></pre> <p>OR</p> <pre><code>+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations </code></pre> <p>For a great tutorial see <a href="http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial" rel="nofollow">this</a>.</p> <p>This is an example if you don't have a lot of time.</p> <pre><code>[UIView animateWithDuration:1//Amount of time the animation takes. delay:0//Amount of time after which animation starts. options: UIViewAnimationCurveEaseOut//How the animation will behave. animations:^{ //here you can either set a CGAffineTransform, or change your view's frame. //Both will work just fine. yourBarView.transform = CGAffineTransformMakeScale ( scaleForX,//say 1, you dont want it to change. scaleForY//say 20, you want to make it 20 times larger in the y //direction. //Note* to animate from a zero height to a finite height change the //view's frame. //yourBarView.frame = CGRectMake(0,0,20,100); ); } completion:^(BOOL finished){//This block is called when the animation completes. NSLog(@"Done!"); }]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload