H. Ferrence H. Ferrence - 1 year ago 188
Swift Question

How to set Xcode/Swift Background Color to Custom

I want to set the background color of my mobile app to #B2B27A.

I can get to View Controller and the Background color panel, but I cannot figure out how to set my own RGB color. Is that possible to do?

Answer Source


self.view.backgroundColor = UIColor(red: 178/255, green: 178/255, blue: 122/255, alpha: 1)

The rgb values are equal to #B2B27A.

You can also add an hex/rgb value in your Storyboard: enter image description here

  1. Select your view
  2. Click background in attributes inspector
  3. Select the second menu item in the colors window
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download