1

How do I set direct view background color of for a view controller in my app using UIAppearance without affecting all of its subviews? It seems like iOS 7 is forcing all bar button items to assume the blue color?

Boon
  • 40,656
  • 60
  • 209
  • 315
  • possible duplicate of [iOS set background color for all viewcontroller self.view's](http://stackoverflow.com/questions/13398544/ios-set-background-color-for-all-viewcontroller-self-views) – artur Nov 25 '14 at 20:58
  • Not a duplicate - I only want direct view, not its subviews. – Boon Nov 26 '14 at 00:30

1 Answers1

1

Unfortunately, you can't accomplish this using the appearance proxy. However, one solution if you are using swift and loading your view controllers from storyboards or nibs is to extend UIViewController and override awakeFromNib like so:

extension UIViewController {

    open override func awakeFromNib() {
        super.awakeFromNib()

        view.backgroundColor = UIColor.blue
    }
}
SilenceDogood
  • 71
  • 1
  • 2