OGeek|极客世界-中国程序员成长平台

标题: ios - 如何从另一个 UIViewController 向下滑动 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 02:53
标题: ios - 如何从另一个 UIViewController 向下滑动

我不知道标题是否明确,所以我将在这里进行更多解释。 我现在有一个 UIViewController 和一个链接到 IBAction< 的 UIButton/code> 触发另一个 UIViewController。我想通过让用户向上滑动来避免点击这一步,就像拖动其他 UIViewController 一样。我发现的一切都只是 UIGestureRecognizer,但我找不到任何控件或任何教程来拖动 UIViewController。 基本上,如果我制定这种 child 方式,我想用一个手指手势从底部滑动 UIViewcontroller,并且 UIViewController 确实跟随我的手指。 感谢您的帮助!

编辑:我不使用 Storyboard ,顺便说一句



Best Answer-推荐答案


导入 QuartzCore 框架并为你想要的做这个,就像一个窗口从底部出现,就像在 ios7 控制中心中一样

- (void)viewDidLoad
    {
        upwardView=[[UIView alloc]init];
        upwardView.backgroundColor=[UIColor blueColor];


        UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self actionselector(didSwipe];
        gesture.direction = UISwipeGestureRecognizerDirectionUp;
        [self.view addGestureRecognizer:gesture];
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }
    -(void)didSwipeUIGestureRecognizer *)gestureRecognizer
    {
        [upwardView setFrame:CGRectMake(0, 265, 320, 230)];
        CATransition *animation = [CATransition animation];
        [animation setType:kCATransitionPush];
        [animation setSubtype:kCATransitionFromTop];
        [animation setDuration:.50];
        [animation setDelegate:self];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
        CALayer *layer = [upwardView layer];
        [layer addAnimation:animation forKey:nil];
        [self.view.window addSubview:upwardView];
    }

关于ios - 如何从另一个 UIViewController 向下滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17162849/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4