2017-04-08 47 views
0

我的视图控制器中有一个UISearchController,当searchBar处于活动状态时,状态栏变为透明。我试过thisthis但他们都没有工作。当searchBar处于活动状态时,statusBar变为透明

enter image description here

这是视图控制器的视图层次:

enter image description here

如何让状态栏半透明?

+1

试试这个:http://stackoverflow.com/a/32235444/2108547 –

+0

@DanielStorm很棘手,但这个http://stackoverflow.com/ a/34229176/689779工作。如果你发布一个答案,我会标记它。 – Maysam

回答

0

viewDidLoad使用此解决了这个问题:

var frame = UIApplication.shared.statusBarFrame 
     frame = CGRect(x: 0, y: 0, width: frame.width, height: frame.height*3.3) 
//3.3 is a practical number 
     let statusBarView = UIView(frame: frame) 
     statusBarView.backgroundColor = sharedApplication.mainThemeColor 
     searchController.view.addSubview(statusBarView) 
相关问题