良い日..私はこのコードを持っています..そしてこの2つはactionAnimatingButtonとstopAnimatingButton用です..これらの2つのボタンを1つのボタンに統合する方法を知りたいだけです..たとえば..ボタンをクリックしてからそれアニメーション..そのactionAnimatingボタンをもう一度クリックすると、アニメーションをキャンセル/停止すると同時に、再生/アニメーションをやり直したい..つまり、actionAnimatingボタンをもう一度クリックするとアニメーションをキャンセルしたい。
-(void)flowerAnimationSequence//START ANIMATION
{
MotherView.alpha = 0;
flower.alpha = 0;
[animationContainer1 removeFromSuperview];
actselected = YES;
NSLog(@"start");
if (((sequenceAnimateCounter == 0) || (sequenceAnimateCounter==1)) && (actselected = YES))
{
aImageViewSlideShow = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
aImageViewSlideShow.tag = 171;
[self.view addSubview:aImageViewSlideShow];
}
if (sequenceAnimateCounter < 183)
{
timer = [NSTimer scheduledTimerWithTimeInterval:0.035 target:self selector:@selector(flowerAnimationSequence) userInfo:nil repeats:NO];
}
else if (sequenceAnimateCounter ==183)
{
aImageView = (UIImageView *)[self.view viewWithTag:171];
NSLog(@"done");
actselected = NO;
sequenceAnimateCounter = 0;
[aImageView removeFromSuperview];
aImageView = nil;
[self DefaultPosition];
}
aImageView = (UIImageView *)[self.view viewWithTag:171];
NSString *aStrNumber = [NSString stringWithFormat:@"%i",sequenceAnimateCounter];
NSString *aBundlePath = [[NSBundle mainBundle]bundlePath];
NSString *aImagePath = [NSString stringWithFormat:@"%@/sapatos_%@.png",aBundlePath,aStrNumber];
[aImageView setImage:[UIImage imageWithContentsOfFile:aImagePath]];
[self.view bringSubviewToFront: aImageView];
sequenceAnimateCounter = sequenceAnimateCounter+1;
if (sequenceAnimateCounter == 1)
{
[aImageView removeFromSuperview];
}
}
-(void)stopanim//STOP BUTTON
{
[timer invalidate];
sequenceAnimateCounter =0;
NSLog(@"stop");
[aImageView removeFromSuperview];
}
前もって感謝します!