I have 10 UIButtons in my application. Now i want to move all these UIButtons with a little gap between all these from the point ( x=-10; y=260; ) to final point ( x=490; y=260; ) landscape view point. I know all these type of animation perform using UIView Code Animation Block or Simple UIView Animation. But I have some concern when using these method to perform animation on UIButtons.
And last thing I want that my
But Still need a lot of work to make its according to above Creteria.
Any help will be appreciated. Thanx in Advance.
How to create gape between these UIButtons beacuse all these Buttons have same starting point.
- When any UIButton Touch the end point (that i define above ) how this UIButton again start animation immediately from the Starting point (that i define above ).
- IF Some of UIButton deleted during animation (for this delation one of the fuction i have in my application) then the UIButton which follow the Deleted UIButton change the location and get the deleted UIButtons location.
- How to perform these UIButtons animation Continiously untill the last UIButtons present on the Screen.
And last thing I want that my
- Animation get start as my view load.
Code:
- (void)moveToLeft:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
btn1.hidden=YES;
btn2.hidden=YES;
btn3.hidden=YES;
btn4.hidden=YES;
btn5.hidden=YES;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(faceRight:finished:context:)];
btn1.center = CGPointMake(-370, 260);
btn2.center = CGPointMake(-290, 260);
btn3.center = CGPointMake(-210, 260);
btn4.center = CGPointMake(-130, 260);
btn5.center = CGPointMake(-50, 260);
[UIView commitAnimations];
}
- (void)faceRight:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(moveToRight:finished:context:)];
btn1.transform = CGAffineTransformMakeRotation(0);
btn2.transform = CGAffineTransformMakeRotation(0);
btn3.transform = CGAffineTransformMakeRotation(0);
btn4.transform = CGAffineTransformMakeRotation(0);
btn5.transform = CGAffineTransformMakeRotation(0);
[UIView commitAnimations];
}
- (void)moveToRight:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
btn1.hidden=NO;
btn2.hidden=NO;
btn3.hidden=NO;
btn4.hidden=NO;
btn5.hidden=NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:20.0];
[UIView setAnimationDelay:0.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDidStopSelector:@selector(faceLeft:finished:context:)];
btn1.center = CGPointMake(490, 260);
btn2.center = CGPointMake(590, 260);
btn3.center = CGPointMake(690, 260);
btn4.center = CGPointMake(790, 260);
btn5.center = CGPointMake(890, 260);
[UIView commitAnimations];
}
- (void)faceLeft:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[UIView setAnimationDelay:0.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDidStopSelector:@selector(moveToLeft:finished:context:)];
btn1.transform = CGAffineTransformMakeRotation(M_PI);
btn2.transform = CGAffineTransformMakeRotation(M_PI);
btn3.transform = CGAffineTransformMakeRotation(M_PI);
btn4.transform = CGAffineTransformMakeRotation(M_PI);
btn5.transform = CGAffineTransformMakeRotation(M_PI);
[UIView commitAnimations];
}
- (void)viewDidLoad {
[self moveToLeft:nil finished:nil context:nil];
[super viewDidLoad];
}
Any help will be appreciated. Thanx in Advance.
Last edited by a moderator: