gpt4 book ai didi

iOS - UIScrollView 从半屏到全屏

转载 作者:行者123 更新时间:2023-11-29 03:15:46 26 4
gpt4 key购买 nike

UIViewController 中,我有一个占据屏幕一半的 UIScrollView。此 UIScrollView 包含 UIView 的集合。在某些特定事件中,例如滑动,我希望我的 UIScrollView 以动画方式全屏显示,如何实现此行为?

最佳答案

试试这个...

// adding swipe gesture to your scrollview
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];

// Set swipe direction.
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[scrollview addGestureRecognizer:swipeLeft];


// add gesture action method
- (void)handleSwipe:(UISwipeGestureRecognizer *)swipe {
// if you are having only one swipe gesture, you no need to add the below condition. you can add the code inside the condition
if (swipe.direction == UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"Left Swipe");
scrollView.contentSize = self.view.frame;
scrollView.frame = self.view.frame;
}
}

关于iOS - UIScrollView 从半屏到全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21722010/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com