gpt4 book ai didi

IOS视差和PageControll

转载 作者:行者123 更新时间:2023-11-28 17:52:32 27 4
gpt4 key购买 nike

我正在寻找任何可以帮助我制作具有视差效果的 Controller 的库。

我需要顶部的 map (我的第一个 Controller )和底部的页面控件,具有视差效果的可滚动顶部以及具有标准效果的左右滚动。

知道怎么做吗?

这与 Google Maps App 的效果相同(在查找地点时)。

最佳答案

您好,如果您想对您的 View 产生视差效果。您应该使用 UIMotionEffects。此 API 将使您有机会设置漂亮且易于管理的视差效果。请记住,视差图像应该比原始图像大一点。

// Set vertical effect
UIInterpolatingMotionEffect *verticalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.y"
type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
verticalMotionEffect.minimumRelativeValue = @(-10);
verticalMotionEffect.maximumRelativeValue = @(10);

// Set horizontal effect
UIInterpolatingMotionEffect *horizontalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.x"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @(-10);
horizontalMotionEffect.maximumRelativeValue = @(10);

// Create group to combine both
UIMotionEffectGroup *group = [UIMotionEffectGroup new];
group.motionEffects = @[horizontalMotionEffect, verticalMotionEffect];

// Add both effects to your view
[myBackgroundView addMotionEffect:group];

关于IOS视差和PageControll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28669694/

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