I'd like to create a view similar to the maps settings menu and the apple pay menu. I tried to make a segue that came from the bottom but couldn't find how to make it smaller than the full screen.
Example:
I'd like to create a view similar to the maps settings menu and the apple pay menu. I tried to make a segue that came from the bottom but couldn't find how to make it smaller than the full screen.
Example:
I ended up creating an xib file (just called "view") and setting the background to transparent. I then added the file to my ViewController and animated it from the bottom when I needed it (all from ViewController.swift)
This was linked to the button to show the menu in the main view controller's file
@IBAction func showSettings() {
let settingsViewVC = SettingsMenuController()
self.addChildViewController(settingsViewVC)
self.view.addSubview(settingsViewVC.view)
settingsViewVC.didMove(toParentViewController: self)
let height = view.frame.height
let width = view.frame.width
settingsViewVC.view.frame = CGRect(x: 0, y: self.view.frame.maxY, width: width, height: height)
}
This was linked to a button that covers the top area of the screen to close the view when you tap off of it
@IBAction func exit() {
UIView.animate(withDuration: 0.6, animations: { [weak self] in
let frame = self?.view.frame
self?.view.frame = CGRect(x: 0, y: frame!.maxY, width: frame!.width, height: frame!.height)
})
}
I am sure there are better ways to do this with storyboards, but this works
Easiest way to produce something like this is following:
UIViewController
with desired components.backgroundColor
as transparent ( or opacity if you wish darkened background on parent ) for topmost view in view controllerThis way you will be able to show your controls with visible parent view controller - depends on your opacitiy it could be 1-1 visiblity or little bit shadow over it. Also you will have full control over componenets so cornerRadius
shown in the picture won't be problem.
I would add tap gesture as well on the topmost view so you can dismiss it that way.