change position of imageview with animation
i want to change position of imageview with animation. it just like draw playing card and it will sets to center anyone here who help me for this.
Code-:
@interface PockerAppViewController : UIViewController
{
UIButton *btn;
UIImageView *cards;
}
@property(nonatomic,retain) IBOutlet UIButton *btn;
@property(nonatomic,retain) IBOutlet UIImageView *cards;
-(IBAction)hidebtn:(id)sender;
-(void)setCards;
@end
--------------------------------.mfile-----------------------------
@implementation PockerAppViewController
@synthesize btn,cards;
/* // The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// Custom initialization
}
return self;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
cards = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"King.png"]];
//[cards setHidden:TRUE];
}
-(IBAction)hidebtn:(id)sender
{
[btn setHidden:TRUE];
[self setCards];
}
-(void)setCards
{
[cards setFrame:cards.frame];
[UIView beginAnimations:@"Move" context:nil];
[UIView setAnimationDuration:0.3];
[cards setCenter:CGPointMake(60,240)];
[UIView commitAnimations];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint pos = [touch locationInView:touch.view];
NSLog(@"X: %f",pos.x);
开发者_如何学编程NSLog(@"X: %f",pos.y)
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
this is my data it help me to solve this problem..
Try something like this:
[URImageView setFrame:CurrentPositionFrame];
[UIView beginAnimations:@"animateTableView" context:nil];
[UIView setAnimationDuration:0.4];
[URImageView setFrame:ToTheNewPositionFrame];
[UIView commitAnimations];
As Till pointed you can also use the Center property:
[UIView beginAnimations:@"animateTableView" context:nil];
[UIView setAnimationDuration:0.4];
[URImageView setCenter:CGPointMake(nPositionX ,nPositionY)];
[UIView commitAnimations];
Thanks Till.
think this could be helpful http://www.flashgamehole.com/Tong/play-game/en/
精彩评论