corocraft
corocraft

Reputation: 150

Transparent UIView on google maps - Swift

I'm trying to put a UIView on google maps and make this UIView transparent to be able to see the background map. As in the following image:

enter image description here

My code is:

    @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

And the result I get putting the uiview as UIColor.clear is: enter image description here

My interface: enter image description here

Upvotes: 1

Views: 839

Answers (1)

Halil İbrahim YILMAZ
Halil İbrahim YILMAZ

Reputation: 740

You should select view on storyboard and change color property with opacity

or

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

Upvotes: 1

Related Questions