gpt4 book ai didi

ios - 谷歌地图上的透明 UIView - Swift

转载 作者:行者123 更新时间:2023-11-28 06:21:09 24 4
gpt4 key购买 nike

我试图在谷歌地图上放置一个 UIView 并使这个 UIView 透明以便能够看到背景 map 。如下图所示:

enter image description here

我的代码是:

    @IBOutlet weak var mapViewContainer: UIView!
var resultsArray = [String]()
var googleMapsView : GMSMapView!
var estacionamientoSelecccionado = Estacionamiento()
@IBOutlet weak var viewTitutlo: UIView!

override func viewDidLoad() {
super.viewDidLoad()

let camera = GMSCameraPosition.camera(withLatitude: (estacionamientoSelecccionado?.latitude)!,
longitude: (estacionamientoSelecccionado?.longitude)!, zoom: 15)
self.googleMapsView = GMSMapView.map(withFrame: self.mapViewContainer.frame, camera: camera)
self.view.addSubview(self.googleMapsView)

let position = CLLocationCoordinate2D(latitude: (estacionamientoSelecccionado?.latitude)!, longitude: (estacionamientoSelecccionado?.longitude)!)
let marker = GMSMarker(position: position)
marker.icon = UIImage(named: "marker_2")!
marker.map = self.googleMapsView
self.viewTitutlo.backgroundColor = UIColor.clear
self.viewTitutlo.isOpaque = false

我将 uiview 设置为 UIColor.clear 的结果是: enter image description here

我的界面: enter image description here

最佳答案

您应该在 Storyboard上选择 View 并使用不透明度更改颜色属性

customView.backgroundColor = UIColor.white.withAlphaComponent(0.3)

关于ios - 谷歌地图上的透明 UIView - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43440984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com