你可以做这样的事情在的viewController 1,当你点击一个按钮:
let ShareVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ShareVC") as! ShareVC
ShareVC.image = returnFinalImage()
self.addChildViewController(ShareVC)
ShareVC.view.frame = self.view.frame
self.view.addSubview(ShareVC.view)
ShareVC.didMove(toParentViewController: self)
然后,只需设定的阿尔法值第二的viewController的主视图中viewDidLoad()
这样的:
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
self.showAnimate()
}
func showAnimate(){
self.view.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
self.view.alpha = 0.0;
UIView.animate(withDuration: 0.25, animations: {
self.view.alpha = 1.0
self.view.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
});
}
func removeAnimate(){
UIView.animate(withDuration: 0.25, animations: {
self.view.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
self.view.alpha = 0.0;
}, completion:{(finished : Bool) in
if (finished)
{
self.view.removeFromSuperview()
}
});
}
@IBAction func closeAction(_ sender:UIButton) {
removeAnimate()
}
或者你也可以模态地prese
let popup : PopupVC = self.storyboard?.instantiateViewControllerWithIdentifier("PopupVC") as! PopupVC
let navigationController = UINavigationController(rootViewController: popup)
navigationController.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
self.presentViewController(navigationController, animated: true, completion: nil)
希望这是有帮助的:使用塞格斯并设置其表现特性,以“在目前的情况下”从属性检查
或者从代码中你可以这样做NT的视图控制器。快乐的编码。 :)
这是一个iPhone应用程序的所有控制“MMPopupView”?如果是,那么请继续可可,并找到适合你的为https://www.cocoacontrols.com/search?q = pop –
嗨,我已经经历了可可控制,并且使用过这些弹出窗口。我需要知道什么是最好的方法。使用单独的视图控制器或在同一视图控制器上创建新视图?提前致谢! – NavodaP