swift - 如何在 swift 3 中更改 googlemap 的 myLocationButton 的位置

标签 swift google-maps swift3 google-maps-sdk-ios

我想将 myLocationButton 放置在我的 iOS 应用程序的右上角,但似乎找不到方法。任何帮助将不胜感激

最佳答案

最简单的方法是为此 View Controller 或其 xib 添加一个导航栏到 Storyboard的顶部。如果此 View Controller 已嵌入导航 Controller 中,您可以跳过此步骤。

enter image description here

从那里,您可以将导航项添加到左侧或右侧栏,这些导航项可以像任何其他对象一样由 View Controller 控制。

enter image description here

那么您总是可以将按钮放在 Storyboard页面上并使用自动约束吗?您还可以以编程方式创建位于右上角的按钮,类似于:

Let myLocationButton = UIButton(frame:CGRect(x:self.view.frame.size.width - (the width of your button), y: 0, width: (the width of your button), height: (the height of your button)) 

然后使用点语法(例如文本或图像)将您想要的任何其他属性添加到按钮。然后将其添加为 subview :

self.view.addSubview(myLocationButton)

关于swift - 如何在 swift 3 中更改 googlemap 的 myLocationButton 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41826448/

相关文章:

javascript - 从谷歌地图中删除自定义叠加层

ios - WCSession sendMessageData 在 watchOS 3 中不起作用

ios - 如何解码 swift 3 中的 unicode 字符?

swift - 在 Swift 中将 JSONEncoder 用于 Equatable 方法

ios - 单击切换按钮展开/折叠 UITableViewCell 高度

ios - 我如何使用谷歌地图构建跟踪其他 gps 用户功能?

javascript - 在 Meteor 应用程序中使用百度 map 与谷歌地图 API

swift - 我无法在 Swift 3 的 navigationController 中执行我的 segue

ios - Realm 添加(_,更新: true) removes existing relationships

ios - 如何扩展 UIBezierPath 弧的外边缘