我不知道标题是否明确,所以我将在这里解释一下。
目前我的 UIViewController
和 UIButton
与 IBAction
相关联另一个UIViewController
。我想通过让用户向上滑动来避免这一点击,就像拖动另一个UIViewController
一样。我找到的所有内容都只是 UIGestureRecognizer
,但我找不到任何控件或任何教程来拖动 UIViewController
。
基本上,如果我制定这个儿童方式,我想用一根手指从底部滑动 UIViewcontroller
,并且 UIViewController
< / strong>跟着我的手指。
谢谢你的帮助!
编辑:我不使用故事板,顺便说一下
答案 0 :(得分: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];
}