[英]swift: uicollectionview changes contentoffset of the cell during transition
我有一個簡單的UICollectionView,帶有一個NavigationController內的自定義單元格。 由於某些原因,當我按下viewController時,collectionView單元會在過渡期間更改其布局。
這是viewController過渡期間uicollectionview的一些常見行為嗎? 因為,例如:標簽沒有這樣的問題
單擊后退按鈕時 ,collectionView中的綠色
添加新的視圖控制器
navigationController?.pushViewController(controller, animated: true)
collectionView.easy.layout([
Top(),
Right(),
Width(view.frame.width),
Bottom(10).to(button),
])
button.easy.layout([
Center(),
Height(60),
Width(300),
])
我想我已經找到了您的問題,它在您的AppDelegate中。 為您的導航控制器設置為false的屬性isTranslucent
似乎解決了這一罕見問題。 像上面一樣,半透明的導航欄將位於視圖控制器視圖的頂部。 一個不透明的導航欄會向下推您的視圖控制器的視圖,或者換句話說,將其縮放以使其適合其下方。.但是為什么collectionview會像它那樣動畫,這實際上是我無法給出確切答案的。 也許其他人可以做到?
為了使導航欄保持透明,可以在視圖控制器中將另一個屬性“ extendedLayoutIncluedsOpaqueBars”設置為true。
所以..這樣做。 在您的AppDelegate中:
window = UIWindow(frame: UIScreen.main.bounds)
window!.makeKeyAndVisible()
let controller = TestingNavigationController()
let navigation = UINavigationController(rootViewController: controller)
window!.rootViewController = navigation
let navigationBarAppereance = UINavigationBar.appearance()
navigationBarAppereance.isTranslucent = false
然后,在視圖控制器的viewDidLoad方法中添加以下行
extendedLayoutIncludesOpaqueBars = true
希望這能解決您的問題! :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.