iOS 8: Presenting a modal view controller in portrait causes resize of the navigation bar of the underlying landscape navigation controller

北城余情 提交于 2019-12-03 03:02:01

For lack of a better option I've done a bit of a hack for this. Basically before I show the modal view I take a screen shot and lay it on top of the presenting view controller.

Obviously I have to remove this screen shot when the view re-appears

  func showScreenShot () {
    let image = screenShot()
    self.screenShotImageView = UIImageView(image: image)
    self.view.addSubview(self.screenShotImageView!)
  }

func screenShot () -> UIImage {
    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, true, UIScreen.mainScreen().scale)
    self.view.layer.renderInContext(UIGraphicsGetCurrentContext())
    let image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image
}

func removeScreenShot () {
  if let screenImageView = self.screenShotImageView {
   screenImageView.removeFromSuperview()
   self.screenShotImageView = nil
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!