将后退按钮的动画从左右滑动更改为左右滑动!导航

发布于 2024-10-09 18:49:41 字数 310 浏览 0 评论 0原文

-(IBAction) takeNextStep : (id) sender
{   
     SecondViewController *varSecondViewController =[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
}

如何将默认的从左到右(向前)滑动更改为从右到左(向后)滑动 由于我有一个自定义按钮,因此我设法对自定义按钮进行编程以返回到根目录,但是它从右向左滑动,从而导致用户困惑,

谢谢!

-(IBAction) takeNextStep : (id) sender
{   
     SecondViewController *varSecondViewController =[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
}

how do i change it from the default sliding from left to right (Forward) to right to left (backwards)
as i have a custom button thus i managed to program my custom button to go back to the root , however it slides from right to left thus causing user confusion

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浴红衣 2024-10-16 18:49:42

您可能会使用这样的东西...

(需要

- (void)switchTwoViews:(UIView *)view1 otherView:(UIView *)view2 direction:(int)directionRL{
    view2.bounds = CGRectMake(0, 0, 480, 320);
    visibleView = view2;
    // remove the current view and replace with view1
    [view1 removeFromSuperview];
    [currentOptionsView addSubview:view2];

    // set up an animation for the transition between the views
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    if (directionRL == 0) {
        [animation setSubtype:kCATransitionFromRight];
    } else {
        [animation setSubtype:kCATransitionFromLeft];
    }

    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[currentOptionsView layer] addAnimation:animation forKey:@"SwitchToView"];
}

这是一个自定义函数,可以将视图从右向左滑动(方向= 0),反之亦然(方向= 1)。

试一试吧。享受。

You might use something like this...

(Requires < QuartzCore/QuartzCore.h >)

- (void)switchTwoViews:(UIView *)view1 otherView:(UIView *)view2 direction:(int)directionRL{
    view2.bounds = CGRectMake(0, 0, 480, 320);
    visibleView = view2;
    // remove the current view and replace with view1
    [view1 removeFromSuperview];
    [currentOptionsView addSubview:view2];

    // set up an animation for the transition between the views
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    if (directionRL == 0) {
        [animation setSubtype:kCATransitionFromRight];
    } else {
        [animation setSubtype:kCATransitionFromLeft];
    }

    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[currentOptionsView layer] addAnimation:animation forKey:@"SwitchToView"];
}

That's a custom function that slides a view from right to left (direction = 0) or vice versa (direction = 1).

Give it a go. Enjoy.

随遇而安 2024-10-16 18:49:41

与 Xen 的答案类似,请在此处下载示例代码

// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];

UIView *newView = aTwoViewController.view; 

// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:newView];

// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView2"];

Similar to Xen's answer, download the sample code here.

// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];

UIView *newView = aTwoViewController.view; 

// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:newView];

// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView2"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文