简体   繁体   中英

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

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.

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM