【iOS】那些年源碼中的Tips...

  1. RESideMenu-> UIInterpolatingMotionEffect->視覺差效果(iOS7)
  2. RESideMenu-> 制作類似UINavigationController、UITabBarController的控制器容器

RESideMenu

  1. 視覺差效果
    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];
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 內容抽屜菜單ListViewWebViewSwitchButton按鈕點贊按鈕進度條TabLayout圖標下拉刷新...
    皇小弟閱讀 46,877評論 22 665
  • 過年這段時間在家里跟爸媽親人聊天嘮嗑的時間居多,漸漸的疏遠了手機,落下了許多朋友圈的東西。 終于在完成了每年過年必...
    梅橋南四三閱讀 448評論 1 1
  • 你在干嘛呀 昨天晚上夢到你了喔 你帶我去吃了那家我一直想吃的小火鍋 霧氣騰騰里你紅著臉跟我說 “慢點吃 小心燙” ...
    秦二佛爺閱讀 236評論 0 0
  • 今天的事實在太逗,得寫出來以后可以回味。提醒一下觀看的各位帥哥美女們。下面的文字可能涉及18歲以上的東西,請想清...
    承思而行閱讀 136評論 0 1
  • 滴答滴答,一個個番茄不知不覺被吃掉,又完成了清單上一項任務,很有成就感。最近在學習使用番茄工作法,簡單易上手的...
    hxleihao閱讀 482評論 0 0