【问题标题】:IOS Parallax and PageControllIOS视差和PageControll
【发布时间】:2015-02-23 08:39:38
【问题描述】:

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

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

知道怎么做吗?

这与谷歌地图应用程序(查找地点时)的效果相同。

【问题讨论】:

标签: ios parallax uipagecontrol


【解决方案1】:

您好,如果您想对您的视图产生视差效果。你应该使用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];

【讨论】:

  • 可以,但我不能。
猜你喜欢
  • 2018-05-23
  • 1970-01-01
  • 1970-01-01
  • 2012-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多