添加滑動手勢你仰視圖。
UISwipeGestureRecognizer *ges =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
[bottomView addGestureRecognizer:ges];
- 刷卡處理器 -
-(void)swipe:(UISwipeGestureRecognizer *)swipeGes{
if(swipeGes.direction == UISwipeGestureRecognizerDirectionUp){
[UIView animateWithDuration:.5 animations:^{
//set frame of bottom view to top of screen (show 100%)
bottomView.frame =CGRectMake(0, 0, 320, bottomView.frame.size.height);
}];
}
else if (swipeGes.direction == UISwipeGestureRecognizerDirectionDown){
[UIView animateWithDuration:.5 animations:^{
//set frame of bottom view to bottom of screen (show 60%)
bottomView.frame =CGRectMake(0, 300, 320, bottomView.frame.size.height);
}];
}
}
我想你想模仿類似Facebook的iOS應用程序的圖片瀏覽器?用戶能夠拉起文本來查看它? 您是否希望用戶能夠平移底部視圖(用手指向上/向下移動它),還是希望用戶能夠點擊它以顯示完整視圖並重新點擊以隱藏它? – n00bProgrammer
只需用手指將其拉起來,然後當用戶到達屏幕頂部時,它會固定在它上面,然後他可以下拉到第一個狀態 –