Reputation: 35
I am working in ios 7. I am beginner to xcode. I am using storyboard. By clicking any row of table from 1st view it goes to 2nd view and prints the number of section and number of row which is clicked. I want that label in which row number is printed come with an animation like coming from left or right side or whatever. Can anyone help me with that?
Upvotes: 1
Views: 1370
Reputation: 1837
you can use UIView animation very easily for this purpose. The usage depends on how your are placing your label on screen.
1- if you've placed it on your view using storyboard and you are using auto layout, you need to link your constraint to an outlet in your view controller's header file for animating the constant value.
[UIView animateWithDuration:0.2f animations:^{self.labelConstrint.constant=anyNumberoulike;
[self.view layoutIfNeeded];
}];
2- if you are using storyboard without the auto layout (which you should) or if you are creating you label in code, the animation is simply animating the x or y part of the label's frame rect.
[UIView animateWithDuration:0.2f animations:^{
self.label.frame=CGRectMake(finaLocationsX,self.label.frame.origin.y,self.label.frame.size.width, self.label.frame.size.height);
}];
Upvotes: 2
Reputation: 121
ViewDidLoad--
YOURLABEl=[[UILabel alloc]init];
YOURLABEl.frame=CGRectMake(x, y, width, height);
[self.view addSubview:YOURLABEl];
[self.view bringSubviewToFront:YOURLABEl];
[self StartButtonAnimate];
--> then make a method to make it animate
-(void)StartButtonAnimate
[UIView beginAnimations:Nil context:Nil];
[UIView setAnimationDuration:2];
YOURLABEl.transform=CGAffineTransformMakeTranslation(for X coordinate,for Y coordinate);
[UIView commitAnimations];
Remeber for transaltion it will use the frame size of your UILabel ,so pass for X and for Y accordingly.
Upvotes: 0
Reputation: 34
If you want a little animation on UILabel when you change the text than first you need to create a CATransition like below.
CATransition *transition = [CATransition animation];
transition.type = kCATransitionFade;
Than after that add a layer of animation to your label.Like below
[self.lblUnit.layer addAnimation:transition forKey:@"changeTextTransition"];
Upvotes: 0