如何定位 myLocationButton google 地图 IOS

how to position myLocationButton google maps IOS

目前,myLocationButton 隐藏在一个按钮后面,如果您看一下按钮,myLocationButton 就在那个按钮后面。如何移动 myLocationButton 的 Y 位置?

使用 GMSMapViewpadding 来实现这一目标。

self.mapView.padding = UIEdgeInsetsMake(0, 0, 100, 0)

'100' 替换为任何 space 您希望将位置按钮上推的内容。您可能应该将其替换为您的图书按钮的 y-location。例如:

let botPadding = self.view.frame.size.height - self.bookButton.frame.origin.y
self.mapView.padding = UIEdgeInsetsMake(0, 0, botPadding, 0)

您可以将此代码放在任何您想要的地方,也许它会在 viewDidLoad 中工作。但请记住,如果您的书本按钮应该在某个时候消失,您将不得不再次调用它。 要使其动态放置,您可以覆盖 viewDidLayoutSubviews 或类似的。