作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将 myLocationButton 放置在我的 iOS 应用程序的右上角,但似乎找不到方法。任何帮助将不胜感激
最佳答案
最简单的方法是为此 View Controller 或其 xib 添加一个导航栏到 Storyboard的顶部。如果此 View Controller 已嵌入导航 Controller 中,您可以跳过此步骤。
从那里,您可以将导航项添加到左侧或右侧栏,这些导航项可以像任何其他对象一样由 View Controller 控制。
那么您总是可以将按钮放在 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/
我是一名优秀的程序员,十分优秀!