I am trying to animate a UIView
here. It looks like a rectangle, and I just want to translate it to my coordinations.
So, how can I animate it? I tried to find some tutorials, but without success.
I am trying to animate a UIView
here. It looks like a rectangle, and I just want to translate it to my coordinations.
So, how can I animate it? I tried to find some tutorials, but without success.
Here is an example of animating a view to move off screen. You should be able to slightly adjust it for your needs:
[UIView beginAnimations:@"bucketsOff" context:nil];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelegate:self];
//position off screen
[bucketView setCenter:CGPointMake(-160, 377)];
[UIView setAnimationDidStopSelector:@selector(finishAnimation:finished:context:)];
//animate off screen
[UIView commitAnimations];
In iOS 4, the UIView block animation method is easiest:
[UIView animateWithDuration:1.0 animations:^{
myView.frame = myNewFrameRect;
}];
http://developer.apple.com/library/ios/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/clm/UIView/animateWithDuration:animations:
//try this AnimationTransitionCurlDown \UP
-(void)pageDown
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self cache:YES];
[UIView commitAnimations];
}
-(void)pageUP
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self cache:YES];
[UIView commitAnimations];
}
//flip uiviews using animation
-(void)FlipFromLeft
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self cache:YES];
[UIView commitAnimations];
}
-(void)FlipFromRight
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self cache:YES];
[UIView commitAnimations];
}
Use "QuartzCore.framework" With these animations.
-(void)viewSlideInFromRightToLeft:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromRight;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
-(void)viewSlideInFromLeftToRight:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromLeft;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
-(void)viewSlideInFromTopToBottom:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromBottom ;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
-(void)viewSlideInFromBottomToTop:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromTop ;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
[UIView beginAnimations:@"your text" context:nil];
[UIView setAnimationDuration:0.4]; //Your animation duration
[UIView setAnimationDelegate:self];
//
write your code here , what you want to animate
//
[UIView commitAnimations];
Working Fine definitely.