嗨,我正在开发一个应用程序。我为一个视图制作了动画,从左到右和从右到左移动,并更改了该视图中包含的标签的值。但是当我单击左键或右键时,该视图会被删除新视图覆盖旧视图。所以我不想覆盖。只是我想添加新视图。我的代码是
-(void)centerAnimation1:(id)sender
{
UIView *currentView = daysview;
theWindow = daysview;
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
animation.delegate = self;
[animation setDuration:0.4];
[animation setType:kCATransitionMoveIn];
if(rhtolft)
{
[animation setSubtype:kCATransitionFromLeft];
}
else
{
[animation setSubtype:kCATransitionFromRight];
}
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
[currentView removeFromSuperview];
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
if(animate)
{
CATransition *animation = [CATransition animation];
animation.delegate = self;
[animation setDuration:0.4];
[animation setType:kCATransitionMoveIn];
if(rhtolft)
{
[animation setSubtype:kCATransitionFromLeft];
rhtolft=NO;
}
else
{
[animation setSubtype:kCATransitionFromRight];
}
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
animate=NO;
[self.view addSubview:daysview];
}
}
只是我在左键和右键操作方法中调用 centerAnimation1 方法。调用此方法后,我更改了标签值。