Iphone 如何使用CATTransition从右向左移动屏幕的uiview部分
我正在开发一个应用程序,我想用下面的代码将uiview从右向左移动Iphone 如何使用CATTransition从右向左移动屏幕的uiview部分,iphone,Iphone,我正在开发一个应用程序,我想用下面的代码将uiview从右向左移动 -(void)centerAnimation1:(id)sender { theview=qstnview; CATransition *animation = [CATransition animation]; animation.delegate = self; [animation setDuration:0.4]; [animation setType:kCATransitionMoveIn]; if(rhtolft)
-(void)centerAnimation1:(id)sender
{
theview=qstnview;
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]];
//[animation setanima]
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
[[theview layer] addAnimation:animation forKey:@"SwitchToView1"];
[qstnview 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];
}
//[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
//[animation setanima]
[[theview layer] addAnimation:animation forKey:@"SwitchToView1"];
[self.view addSubview:qstnview];
}
}
但这一个正在将视图从右侧最后一个边缘移动到左侧。但我只需要在帧大小内移动。我不需要从右侧边缘开始。因此,请告诉我如何执行此操作。编辑:
[UIView animateWithDuration:0.33f
delay:0.0f
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
animations:^{
[theView setFrame:newFrame]; //set new frame for view where x =200;
}
completion:^(BOOL finished){
// do whatever post processing you want (such as resetting what is "current" and what is "next")
}];
屏幕从右到左使用如下CATTransition
CATransition *animation = [CATransition animation];
[animation setDuration:0.3];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theView layer] addAnimation:animation forKey:@"rightToLeftAnimation"];
我不认为你需要潜入加州去做这种事情。可以使用UIView动画完成此操作。这是一个关于UIView动画的好教程。使用以下代码更改动画图像:
CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype=kCATransitionFromLeft;
[yourImageViewName.layer addAnimation:transition forKey:nil];
我只想在屏幕大小内移动视图。也就是说,我不需要将视图从右边缘移动到左边缘。我需要将视图从x值200移动到x值100。嘿,伙计,看看这个显示输出的链接演示,就知道了。。这就是我一直在寻找的。