- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set background color of a View in iOS App?
Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. A view object renders content within its bounds rectangle and handles any interactions with that content. The UIView class is a concrete class that you can instantiate and use to display a fixed background color.
It is very important to have complete understanding of UIView as they are the main object user sees.
Here we will be seeing how to change the background color of view programmatically and via storyboard.
First let us see using storyboard, Open Main.storyboard and add one view to the View Controller.
On the right pane you can see the property, and from there update the background color to color you want your view to be as show below.
Now let us see how we can change the color programmatically. Use the below code and change the value to desired colour.
self.view.backgroundColor = UIColor.cyan
- How to set background color of a view in Android App
- How do you animate the change of background color of a view on iOS?
- How to get the dimensions of a view in iOS App?
- How to run a timer in background within your iOS app
- How to change background color of TableView items on iOS?
- How to Set opacity for View in iOS?
- How to set background color in jQuery?
- How to set background color in HTML?
- How to set the background color of a ttk.Combobox in tkinter?
- How to set background for Navigation Bar in iOS?
- How to set the background color of a column in a matplotlib table?
- How do you animate the change of background color of a view on Android?
- How can we set a background color to JSplitPane in Java?
- How to set a particular color as background to a JavaFX chart?
- How to customise iOS button to set text and color?