2017-04-16 11 views
0

私はGoogleマップにUIViewを配置し、このUIViewを透明にしてバックグラウンドマップを表示しようとしています。以下の画像のように:Googleマップ上の透明なUIView - Swift

enter image description here

私のコードです: 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 

そして結果UIColor.clearがあるように私はUIViewのを入れますenter image description here

+0

とアンジュの色のプロパティ私の推測では、あなたの 'UIView'がGMSMapView''の下で、 'のUIViewControllerのview.backgroundColor = .green'か何かを設定し、私は右だかどうかをチェックしてみてくださいです。 – JuicyFruit

+0

もし私がself.view.backgroundColor = .greenを設定すると、self.viewTitutlo.backgroundColor = UIColor.clear self.viewTitutlo.isOpaque = false、私のself.viewTitutloの背景は緑ですが、私はself.view.backgroundColor = UIColorを設定します。クリア、背景は黒です。 – corocraft

+0

さて、あなたの問題はあなたのレイアウトが間違っていることです.GMSMapViewはUIViewの一番下にあります。 – JuicyFruit

答えて

0

あなたはストーリーボードとch不透明度

または

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

self.viewTitutlo.backgroundColor = UIColor.clearを使用したのと同じ結果になります。私は問題は、ビューにマップをロードする方法だと思う。 – corocraft

関連する問題