gpt4 book ai didi

ios - 缩放对分页 UIScrollView 的影响?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:57:09 25 4
gpt4 key购买 nike

我想在我创建的分页 UIScrollView 上实现“缩放”效果,但我遇到了很多困难。我的目标是,当用户开始滚动到下一页时,当前页面会缩小并变小一点。当下一页出现时,它会放大直到变成全尺寸。我能找到的最接近示例的是...

https://www.pinterest.com/pin/147141112804210631/

任何人都可以给我一些关于如何完成此操作的指示吗?在过去的 3 天里,我一直在用头撞墙。

最佳答案

我会建议使用分页 UIScrollView 的 scrollView.contentOffset.y 来跟踪滚动并使用该值来动画化 UIScrollView 内 View 的转换。

因此,添加您的分页 ScrollView 并将自己设置为委托(delegate)

    paginatedScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [[self view] bounds].size.width, [[self view] bounds].size.height-paginatedScrollViewYOffset)];
[self.view addSubview:paginatedScrollView];

paginatedScrollView.pagingEnabled = YES;
[paginatedScrollView setShowsVerticalScrollIndicator:NO];
[paginatedScrollView setShowsHorizontalScrollIndicator:NO];
[paginatedScrollView setAlwaysBounceHorizontal:NO];
[paginatedScrollView setAlwaysBounceVertical:YES];
paginatedScrollView.backgroundColor = [UIColor clearColor];

paginatedScrollView.contentSize = CGSizeMake([[self view] bounds].size.width, [[self view] bounds].size.height*2); //this must be the appropriate size depending of the number of pages you want to scroll

paginatedScrollView.delegate = self;

然后使用委托(delegate)方法 scrollViewDidScroll 来跟踪 scrollView.contentOffset.y

- (void) scrollViewDidScroll:(UIScrollView *)scrollView {

NSLog(@"Scroll Content Offset Y: %f",scrollView.contentOffset.y);
//use here scrollView.contentOffset.y as multiplier with view.transform = CGAffineTransformMakeScale(0,0) or with view.frame to animate the zoom effect

}

关于ios - 缩放对分页 UIScrollView 的影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36554774/

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