2

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

编辑:我不使用情节提要,顺便说一句

4

1 回答 1

4

导入 QuartzCore 框架并为您想要的执行此操作,就像在 ios7 控制中心一样从底部出现一个窗口

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


        UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
        gesture.direction = UISwipeGestureRecognizerDirectionUp;
        [self.view addGestureRecognizer:gesture];
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }
    -(void)didSwipe:(UIGestureRecognizer *)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];
    }
于 2013-06-18T07:32:11.267 回答