【发布时间】:2011-08-10 08:11:58
【问题描述】:
我想用动画改变 imageview 的位置。它就像抽纸牌一样,它将集中在这里帮助我的任何人。
代码-:
@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;
/* // 指定的初始化器。覆盖以执行加载视图之前所需的设置。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// Custom initialization
}
return self;
}
// 实现 viewDidLoad 以在加载视图后进行额外设置,通常从 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];
}
这是我的数据,它可以帮助我解决这个问题..
【问题讨论】:
标签: iphone animation uiimageview core-animation position