How can I overlay a search bar over MapKit?

2019-07-24 11:54发布

How can I overlay a search bar over MapKit?

I like how the new Google Maps application has a search box and buttons that hover over the map.

See the image on the left:

The left-most image shows what I mean.

I'm not sure how to get this however as I have not been programming iOS for longer than a couple of weeks. Any ideas on how I could hover UI elements on top of each other with Storyboards/Objective-C?

Presumably it's a navigation bar that has been made invisible but how is this done, and how is it the Map appears underneath it?

1条回答
三岁会撩人
2楼-- · 2019-07-24 12:06

The search box appears to be a custom control which mimics behavior of a UISearchBar and which would inherit from UIControl. Since UIControl inherits from UIView, you can add it to your map view

  1. programatically with the addSubview: method
  2. via Storyboard by adding your custom control to your map in the appropriate view controller
查看更多
登录 后发表回答