Google Maps GMSMapView on custom UIView

后端 未结 8 1640
陌清茗
陌清茗 2020-12-14 20:33

I want to display google maps on a view that\'s then added to self.view, rather than drawing the map directly on self.view. Therefore, I created a

8条回答
  •  醉梦人生
    2020-12-14 21:04

    CGRect.zero will return a view with zero height and zero width. It will be invisible.

    Also, it doesn't really make sense to add it in to the storyboard if you want to do your own allocation. You should instead just create a property of the view controller programmatically, and set its frame to be whatever you want.

    Note, when you call 'addSubview' to a view, it will always be added to the top of the view, so there's no need to insert it at a given index. Using auto-layout is good, but viewDidLoad() gets called before all of the constraints are set. If you want to be able to set your mapView's frame = self.view, you would want to do that in viewDidAppear() instead.

提交回复
热议问题