Google地图全屏显示.如何填充到半屏?

Ork*_*ade 4 iphone xcode google-maps ios swift

我用下一个代码:

var camera = GMSCameraPosition.cameraWithLatitude(40.378259,
        longitude: 49.875059, zoom: 16)
    var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
    mapView.myLocationEnabled = true
    self.view = mapView

    var marker = GMSMarker()
    marker.position = CLLocationCoordinate2DMake(40.378259, 49.875059)
    marker.map = mapView
Run Code Online (Sandbox Code Playgroud)

我使用约束,但它对我没有帮助.即使我执行下一个操作,我的地图也会全屏显示:

var mapView = GMSMapView.mapWithFrame(CGRectMake(0, 0, 100, 100), camera: camera)
Run Code Online (Sandbox Code Playgroud)

为什么它不起作用?我该如何解决?我通过Podfile连接它

Ash*_*kad 6

使用addSubview方法执行此操作.

var mapView = GMSMapView.mapWithFrame(CGRectMake(0, 0, 100, 100), camera: camera)
mapView.myLocationEnabled = true
self.view.addSubview(mapView)
Run Code Online (Sandbox Code Playgroud)