Top layout guide is deprecated in iOS 11

匿名 (未验证) 提交于 2019-12-03 08:41:19

问题:

As topLayoutGuide property is deprecated in iOS 11, What is alternative to use top layout guide

?

backView.topAnchor.constraint(equalTo: topLayoutGuide.topAnchor)

回答1:

TopLayoutGuide is deprecated in iOS 11 so we have option to use SafeAreaLayoutGuide like this :

  • First we can get view safeAreaLayoutGuide
 let guide = view.safeAreaLayoutGuide 
  • Second add constraint to guide

    searchBackView.topAnchor.constraint(equalTo: guide.bottomAnchor).isActive = true 


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