How to constrain static table view controller cells to Safe Area in Swift/iOS

倾然丶 夕夏残阳落幕 提交于 2021-02-11 15:40:26

问题


I have a table view controller with static cells. I’m running on iPhone X and when scrolling, the cells appear to be behind the navigation bar and unsafe area. What is preferred would be a solid orange color in the unsafe area instead of the image presented below. Is this possible? I can’t move to a table view inside of a view controller, which I would then constrain to the safe area, because my cells are static.


回答1:


You need to use a Container View, so add a View Controller in your storyboard and put a Container View in it-by adding the container view it will automatically create a segue and a view controller delete both.

Now from your Container View create a segue to the Table View Controller and choose Embed.

Last step is to set the constraints for your Container View, the most important for your issue is the top one, set it 0 to the safe area.



来源:https://stackoverflow.com/questions/51050550/how-to-constrain-static-table-view-controller-cells-to-safe-area-in-swift-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!