Reputation: 150
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:
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:
Upvotes: 1
Views: 839
Reputation: 740
You should select view on storyboard and change color property with opacity
or
customView.backgroundColor = UIColor.white.withAlphaComponent(0.3)
Upvotes: 1