amm*_*eja 17 iphone google-maps google-maps-api-3 ios currentlocation
我在我的项目中使用谷歌地图我想显示我的位置按钮有点我应该如何使用swift
Sub*_*n P 38
您可以通过为地图视图设置填充来更改MapControls的位置.
let mapView = GMSMapView()
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
mapView.padding = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 50)
Run Code Online (Sandbox Code Playgroud)
它将更改我的位置控件的填充.从底部50px和右边50px
请参阅下面的屏幕截图,其中添加了从底部和右侧50px的填充.
小智 7
swift 4 更新:只需更改我的位置按钮的位置
for object in self.mapView.subviews{
if(object.theClassName == "GMSUISettingsPaddingView"){
for view in object.subviews{
if(view.theClassName == "GMSUISettingsView"){
for btn in view.subviews{
if(btn.theClassName == "GMSx_QTMButton"){
var frame = btn.frame
frame.origin.y = frame.origin.y - 100
btn.frame = frame
}
}
}
}
}
}
public extension NSObject {
public var theClassName: String {
return NSStringFromClass(type(of: self))
}
}
Run Code Online (Sandbox Code Playgroud)
小智 6
像Subramanian一样,这非常有效:
mapView.padding = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0)
Run Code Online (Sandbox Code Playgroud)
如果您的应用中有导航栏,这是完美的.
归档时间: |
|
查看次数: |
12728 次 |
最近记录: |