iPhoneでページをめくるを試してみた

pageCurlをするが途中で止まり、1秒後にもとにもどすをやります




NSTimer *timer;

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
	if(mode==nil || mode==0)
	{
		NSLog(@"end");	
		[cartpictureView removeFromSuperview];
	}
	else
	{
		timer = [NSTimer scheduledTimerWithTimeInterval:1.0
				target:self
				selector:@selector(open_helpview:) 
				userInfo:nil 
				repeats:NO];
		
		[[NSRunLoop currentRunLoop] addTimer:timer  forMode:NSRunLoopCommonModes ];
		
		[timer retain]; 
	}
	
}

UIView *cartpictureView;

- (void)Transition_animation:(id)sender
{

	if(mode==nil || mode==0)
	{
		if(cartpictureView == nil)
		{
			cartpictureView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
			[cartpictureView setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:0.7]];
		}
	
		[self.view addSubview:cartpictureView];
	}
	else {
		[self.view sendSubviewToBack:cartpictureView];
	}
	
	NSLog(@"Curl");
	// Curl the image up or down
	CATransition *animation = [CATransition animation];
	[animation setDelegate:self];
	[animation setDuration:0.35];
	[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
	if (!mode){
		animation.type = @"pageCurl";
		animation.fillMode = kCAFillModeForwards;
		animation.endProgress = 0.55;
    } else {
		animation.type = @"pageUnCurl";
        animation.fillMode = kCAFillModeBackwards;
		animation.startProgress = 0.45;
	}
	[animation setRemovedOnCompletion:NO];
	
	[animation setDelegate:self];
	
	[[self view] exchangeSubviewAtIndex:0 withSubviewAtIndex:2];
	
	[[[self view] layer] addAnimation:animation forKey:@"pageCurlAnimation"];
	
	// Disable user interaction where necessary
	if (mode == nil || mode==0) {
		mode=1;
	} else {
		mode=0;
	}

}