全部, 我想将UILabel向上移动5秒并隐藏起来。 我们在游戏中看到的东西,当我们得到什么的时候, 文字出现,向上移动说“+300”等等。
如何移动UIlabel? 问候
答案 0 :(得分:1)
即
- (void)showScoreLabelFor:(int)score {
// Make a label
UILabel *scoreLabel = [UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] autorelease];
// Set it's text to the score we want to show
[scoreLabel setText:[NSString stringWithFormat:@"%+i", score]];
// Center it in the view
[scoreLabel sizeToFit];
[scoreLabel setCenter:CGPointMake([[self view] center].x, 200)];
// Add it to the view
[[self view] addSubview:scoreLabel];
// Animate it up 100 pixels ver 2 seconds
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
CGRect frame = [scoreLabel frame];
frame.origin.y -= 100;
[scoreLabel setFrame:frame];
[UIView commitAnimations];
}