我做了一个用动画滑动的提示框,但是当用户点击一个蜡烛按钮时我也想要-10个硬币,所以我创建了一系列照片来制作描绘-10的动画给用户......
问题是,每次按下蜡烛按钮时,-10coins动画会覆盖提示滑动框并替换它,从而使用户无法再次找到提示......
代码:
- (IBAction)firstHintq:(id)sender {
[_hintView setHidden:NO];
[_hintViewTwo setHidden:YES];
[_hintViewThree setHidden:YES];
_hintView.text = @"Ηταν η τεταρτη τηλεφωνικη εταιρια στην Ελλαδα";
//connected to global BOOL
if (!btn1Pressed) {
if((coins -10) >= 0){
coins = coins -10;
score = score -2;
// Load images starts
NSArray *imageNames = @[ @"coin-10-1.png", @"coin-10-2.png",
@"coin-10-3.png", @"coin-10-4.png", @"coin-10-5.png", @"coin-10-6.png",
@"coin-10-7.png", @"coin-10-8.png", @"coin-10-9.png", @"coin-10-10.png", @"coin-10-11.png",@"coin-10-12.png", @"coin-10-13.png",@"coin-10-14.png",@"coin-10-15.png"];
NSMutableArray *images = [[NSMutableArray alloc] init];
for (int i = 0; i < imageNames.count; i++) {
[images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
}
// Normal Animation
UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(80, 200, 30, 70)];
animationImageView.animationImages = images;
animationImageView.animationDuration = 1.5;
animationImageView.animationRepeatCount = 10;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];
//coin animation ends
//changes image
[_candleone setImage:[UIImage imageNamed:@"candle2_03.png"] forState:UIControlStateNormal];
self.candletwo.hidden = NO;
//Animates the 2nd candle
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
CGPoint center = [_candletwo center];
center.x = 88;
center.y = 70;
[_candletwo setCenter:center];
[UIView commitAnimations];
//sets the global BOOL as true
coinsLabel.text = [NSString stringWithFormat:@"%d",coins];
btn1Pressed = true;
}
else{
[_hintView setHidden:YES];
//Show an alert that the user has not enough coins
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TITLE" message:@"MESSAGE" delegate:nil cancelButtonTitle:@"RETURN BUTTON" otherButtonTitles:nil];
[alert show];
}
}
}
如何解决此问题,以便两个动画都能正常激活?
答案 0 :(得分:0)
更好地使用动画:
[UIView animateWithDuration:time // time is a double
delay:0.0f
options:UIViewAnimationOptionCurveEaseIn
animations:^() {
}
completion:^(BOOL finished) {
}];
然后你可以使用2 animateWithDuration: delay: options: completion:
OFC,你可以窝2:
[UIView animateWithDuration:time // time is a double
delay:0.0f
options:UIViewAnimationOptionCurveEaseIn
animations:^() {
}
completion:^(BOOL finished) {
[UIView animateWithDuration:time // time is a double
delay:0.0f
options:UIViewAnimationOptionCurveEaseIn
animations:^() {
}
completion:^(BOOL finished) {
}];
}];