我想在iOS {中像控件中心一样向上和向下滑动UIViewController
的主视图。
我看到VC1上可见一半的VC2。现在,当用户使用手指滑动VC2的视图时,它将像控制中心一样上下滑动。
我使用UISwipeGestureRecognizer
向上和向下滑动,但它不像iOS中的控制中心那样动画
修改
- (void)viewDidLoad {
[super viewDidLoad];
UISwipeGestureRecognizer *gestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDownHandler:)];
[gestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
[self.view addGestureRecognizer:gestureRecognizer];
UISwipeGestureRecognizer *gestureRecognizer1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUpHandler:)];
[gestureRecognizer1 setDirection:(UISwipeGestureRecognizerDirectionUp)];
[self.view addGestureRecognizer:gestureRecognizer1];
}
-(void)swipeUpHandler:(UISwipeGestureRecognizer *)recognizer{
[UIView animateWithDuration:0.3 animations:^{
[self.view setFrame:CGRectMake(0,25, self.view.frame.size.width, self.view.frame.size.height)];
}];
}
-(void)swipeDownHandler:(UISwipeGestureRecognizer *)recognizer {
[UIView animateWithDuration:0.3 animations:^{
[self.view setFrame:CGRectMake(0,self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
}];
}
任何人都知道该怎么办?