2016-03-29 18 views
0

iphone peyzaj sorunu,ios - durum çubuğu rengi - ı durum çubuğu rengini değiştirmek için bu kullanarak çalıştı

let proxyViewForStatusBar : UIView = UIView(frame: CGRectMake(0, 0,self.view.frame.size.width, 20))  
proxyViewForStatusBar.backgroundColor=UIColor.purpleColor() 
self.view.addSubview(proxyViewForStatusBar) 

, portre çalışıyor Ve ben iphone manzara onu istemiyoruz.

bu yüzden bu

override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) { 


    let proxyViewForStatusBar : UIView = UIView(frame: CGRectMake(0, 0,self.view.frame.size.width, 20)) 



    if UIDevice.currentDevice().orientation.isLandscape.boolValue && UIDevice.currentDevice().userInterfaceIdiom == .Phone{ 

     proxyViewForStatusBar.backgroundColor = UIColor.clearColor() 
    }else { 
     proxyViewForStatusBar.backgroundColor=UIColor.purpleColor() 
    } 

    self.view.addSubview(proxyViewForStatusBar) 

} 

çalıştı ancak sonuç durum çubuğu kısmen gösterir, biraz garip olur. enter image description here Eklendi.

Herhangi bir yardım için teşekkür ederiz.

+1

Sadece başka yeni vekil görünümü ekleyemezsiniz Açık bir arka plan, zaten var olanı kaldırmanız gerekir. Bir alt görünüm olarak eklemeden önce buna referans göstermeli ve cihaz manzaradayken çıkarmalısınız. – dan

cevap

1

İki kez viewProxy eklediğinizi görüyorum. İlk kez para cezaları. Ancak başka bir görünümü döndürdüğünüzde ve son görünümü hala burada.

Yani görünüm için küresel oluşturabilirsiniz:

var proxyViewForStatusBar : UIView! 

ViewDidload yılında:

proxyViewForStatusBar= UIView(frame: CGRectMake(0, 0,self.view.frame.size.width, 20))  
proxyViewForStatusBar.backgroundColor=UIColor.purpleColor() 
self.view.addSubview(proxyViewForStatusBar) 

döndür zaman:

override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) { 
    proxyViewForStatusBar.frame = CGRectMake(0, 0,self.view.frame.size.width, 20) 
    if UIDevice.currentDevice().orientation.isLandscape.boolValue && UIDevice.currentDevice().userInterfaceIdiom == .Phone{ 

     proxyViewForStatusBar.backgroundColor = UIColor.clearColor() 
    }else { 
     proxyViewForStatusBar.backgroundColor=UIColor.purpleColor() 
    } 

} 
İlgili konular