Można to zrobić poprzez nadpisanie swoją UIViewController
podklasę inicjujące metod, jak ten.
class SomeViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.modalTransitionStyle = .crossDissolve
self.modalPresentationStyle = .overFullScreen
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.modalTransitionStyle = .crossDissolve
self.modalPresentationStyle = .overFullScreen
}
// if this is a xib UIViewController, if not do not add this code
required init() {
// place the "SomeViewController's Nib Name" in the nibName to prevent crashes from iOS 8 devices
super.init(nibName: "SomeViewController's Nib Name", bundle: nil)
}
}
Następnie na innych UIViewController
s można zainicjować wspomnianego ViewController.
XIb i/lub programowo
// instantiate your UIViewController
let viewController = SomeViewController()
self.present(viewController, animated: true, completion: nil)
storyboard
// instantiate the storyboard containing your UIViewController
let storyboard = UIStoryboard(name: "StoryboardName", bundle: nil)
// place UIViewController initialization inside if let block to prevent unwanted crashes
if let viewController = storyboard.instantiateViewController(withIdentifier: "SomeViewController's Identifier") as? SomeViewController {
self.present(viewController, animated: true, completion: nil)
}
Upewnij się, że widok hierarchia wygląda to
ta powinna być ich właściwości
Zobacz
Translucent Ciemne tło Zobacz
- backgroundColor = .black
- alfa = 0,4
Popover Zobacz
.. cokolwiek chcesz to być
wykorzystanie oddzielny widok (XIb) i załadować tam, gdzie trzeba, a następnie usunąć. – vaibhav
Preferuję storyboard – sinusGob
to jest popover i użyj storyboardu do końca projektu. – vaibhav