[英]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.