- RESideMenu-> UIInterpolatingMotionEffect->視覺差效果(iOS7)
- RESideMenu-> 制作類似UINavigationController、UITabBarController的控制器容器
RESideMenu
-
視覺差效果
UIInterpolatingMotionEffect
這個東西其實是iOS7的,原諒我現在才知道。。。效果就是在真機(模擬器沒有傳感器)上面左右或者上下傾斜手機,view會自動根據感應器的傾斜角度對View進行偏移 給人以視覺上的層次感(iOS系統桌面背景圖)
keyPath:左右翻轉屏幕將要影響到的屬性,比如center.x。
type:(UIInterpolatingMotionEffectType類型),觀察者視角,也就是屏幕傾斜的方式,目前區分水平和垂直兩種方式
minimumRelativeValue、maximumRelativeValuev 對應的值的變化范圍,注意這個是id類型。min對應最小的offset,max對應最大的offset。視差的范圍
//最好每次添加效果的時候先移除掉原來的那些效果
for (UIMotionEffect *effect in self.menuViewContainer.motionEffects) {
[self.menuViewContainer removeMotionEffect:effect];
}
UIInterpolatingMotionEffect *interpolationHorizontal = [[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
interpolationHorizontal.minimumRelativeValue = @(self.parallaxMenuMinimumRelativeValue);
interpolationHorizontal.maximumRelativeValue = @(self.parallaxMenuMaximumRelativeValue);
UIInterpolatingMotionEffect *interpolationVertical = [[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
interpolationVertical.minimumRelativeValue = @(self.parallaxMenuMinimumRelativeValue);
interpolationVertical.maximumRelativeValue = @(self.parallaxMenuMaximumRelativeValue);
//這玩意一般最好加到背景圖(ios系統桌面的背景圖)給人以層次感
[self.menuViewContainer addMotionEffect:interpolationHorizontal];
[self.menuViewContainer addMotionEffect:interpolationVertical];