2015-08-19 34 views
0

我想爲整個應用程序使用相同的背景圖像,所以我創建了一個包含導航控制器的正常UIViewController,其中UIImageViewUIContainerView。然後,我將所有的ViewController的背景色清除顏色這是我的故事板:在iOS中的多個視圖中使用UINavigationController中的固定背景圖像?

my storyboard

但是,當我按一下按鈕,它們之間的SEGUE有一些黑色的字母背景。看到這個GIF:

GIF

那麼,有沒有更好的方式來實現這一目標?或者我該如何解決這個問題?謝謝!

+0

你使用過這個[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@「imageName.png」]]] – Jaideep

+0

@Jaideep我希望背景保持靜止,即使視圖已經改變(不移動)( GIF是我想要實現的) – Arefly

+0

「黑色alpha背景」是什麼意思?我看到一條垂直線將視圖控制器分開,但其他所有內容可能只是一個視頻壓縮工件。 – NRitH

回答

0

我會建議繼承UINavigationController的,在你CustomNavController viewDidLoad中:

  • 設置你的UINavigationBar的透明(這可能是你想要的東西太)

    self.navigationBar.setBackgroundImage(UIImage(), for: .default) 
    self.navigationBar.shadowImage = UIImage() 
    
  • 設置你的背景,以填補導航控制器視圖

    let image = UIImage(named: "background") 
    let bgImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)) 
    bgImageView.image = image 
    self.view.insertSubview(bgImageView, at: 0)