0
我已將MKMapView
作爲子視圖添加到視圖控制器的view
(嵌入到導航控制器中),然後我使用錨將其固定到我的側面觀看像這樣:當導航欄被隱藏時,視圖(MKMapView)調整大小
mapView.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor).active = true
mapView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor).active = true
mapView.topAnchor.constraintEqualToAnchor(view.topAnchor).active = true
mapView.bottomAnchor.constraintEqualToAnchor(view.bottomAnchor).active = true
當我使用navigationController?.setNavigationBarHidden(true, animated: true)
隱藏我的導航欄,mapView
變得更高,如果它是不是掛靠在我view
的頂部,但在我的導航欄的底部哪有我。避免這種情況?我想讓導航欄滑出屏幕,留下具有相同位置/高度的全屏mapView。
謝謝!
試試這個: mapView.topAnchor.constraintEqualToAnchor(view.topLayoutGuide)。主動=真 –
「的UIView沒有名爲topLayoutGuide成員」 :( – lucamegh
mapView.topAnchor.constraintEqualToAnchor(topLayoutGuide.bottomAnchor)。主動=真 –