I would like to change the background color of my app programmatically, not IB. Is it possible to get both a Swift and Obj-C answer.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
If you want to change the background color of the view with code in Swift, you should do instead:
You can use RGB Color by following code:
You can set the
backgroundColor
property of whatever view it is you have on screen.In Objective-C:
In Swift:
or if it's the main window you're after,
In Objective-C:
In Swift:
possible colors are :
For Swift 3, you should do:
Unfortunately, the other answers no longer work in Swift 3.
For swift based project you can simply type the following and press enter:
Here the ColorLiteral property will give you a default white colour which you can change by double clicking on that colour.
You can choose from a list of colour from this popup: