iOS設定translucent 引發的座標問題

來源:互聯網
上載者:User

標籤:底部   gen   logs   座標   www   extend   計算   nav   無法   

   iOS  NavigationBar  + 導覽列 tablevie時候的布局情況,之前迷惑了我很久,怎麼也沒法理解透明度會影響布局。

接下來看一下以下三種情況的運行結果

1、全部系統預設情況下利用masory 布局 tableView  
  [tableView mas_makeConstraints:^(MASConstraintMaker *make) {        make.left.top.right.equalTo(self.view);        make.bottom.equalTo(self.view.mas_bottom);    }];

 結果底部發現tableView無法拉到底,如

 

解決方案:只要一句代碼即可

 [tableView mas_makeConstraints:^(MASConstraintMaker *make) {        make.left.top.right.equalTo(self.view);        make.bottom.equalTo(self.view.mas_bottom);//減去底部tabBar高度    }];    self.edgesForExtendedLayout = UIRectEdgeNone;//自動會計算tabBar高度

 

2、全域設定 translucent 導覽列為setTranslucent = NO時
[[UINavigationBar appearance] setTranslucent:NO];

 顯示效果同 1的結果。   解決方案同1

(這裡就很費解,按照系統文檔上解釋的話,預設應該是YES才對,可是事實證明系統預設是NO)

 

3、全域設定 translucent 導覽列為setTranslucent = YES 時

 

[[UINavigationBar appearance] setTranslucent:YES];

 結果發現tableView 高度開始從導覽列左上方開始計算,結果如下:

 

解決方案同1,也是設定edgesForExtendedLayout 屬性

    self.edgesForExtendedLayout = UIRectEdgeNone;

 

 這裡也連結一篇說的比較好的文章:http://www.jianshu.com/p/b11769831fef

 

iOS設定translucent 引發的座標問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.