最近給iOS11 的tableView 添加背景? 發現在iOS8,9,10 中均可以添加成功沒有問題,但在iOS11 中發現tableview 的頂部有一部分被遮擋,于是做了圖層分析,分析圖片如下:
iOS9.1中tableView的圖層
iOS11 中tableView 的圖層
通過圖層分析,我們可以發現 在iOS11 中UItableviewWrapperView 不存在了 導致我們通常添加背景的方式出現錯亂。
常規添加背景代碼如下:
? let?backgroundImageView?=?UIImageView()
backgroundImageView.frame?=?self.view.frame
backgroundImageView.image?=?UIImage(named:"background")
view.insertSubview(backgroundImageView,?at:0)
結合 在蘋果開發者中的相關提問:https://forums.developer.apple.com/thread/86994
做了如下處理:
backgroundImageView.layer.zIndex?=?-1??