2017-07-10 54 views
1

試圖更改UIStatusBarStyleUIImagePickerController文本顏色。嘗試了以下內容:如何更改UIImagePickerController視圖的UIStatusBarStyle文本顏色

imagePicker.navigationBar.isTranslucent = false 
imagePicker.navigationBar.barTintColor = .darkGray 
imagePicker.navigationBar.tintColor = .white 
imagePicker.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white] 

This答案顯示爲指定,即使承運人的標誌和UIStatusBarStyle也改變它的顏色。但它並沒有改變。有沒有其他的東西可以嘗試在UIImagePicker中使UIStatusBarStyle文字顏色變化?

嘗試下面的代碼,正在爲其他UIViewController小號

imagePicker.preferredStatusBarStyle = UIStatusBarStyle.lightContent 
imagePicker.setNeedsStatusBarAppearanceUpdate() 

但不工作。請幫助。謝謝。

回答

4

這是我的代碼 - UIImagePIckerController的一個簡單的子類。

public class ImagePickerController: UIImagePickerController { 

    override public func viewDidLoad() { 
     super.viewDidLoad() 
    } 

    override public func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
    } 

    override public var preferredStatusBarStyle : UIStatusBarStyle { 
     return .lightContent 
    } 
} 
+0

工作就像一個魅力!謝謝。 –

-1

======= 添加UINavigationControllerDelegate,UIImagePickerControllerDelegate您

@interface yourController()<>

=======

imagePickerController.delegate =自我;

=======

- (無效)navigationController:(UINavigationController的*)navigationController willShowViewController:(的UIViewController *)的viewController動畫:(BOOL)動畫 { [[UIApplication的sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent ]。 }

======