Lesson 2 change the background color and background color
In general, almost all software cannot change the color.
Start to add background color.
1. Create a project first
2. Modify ViewController. m (case sensitive)
3. Create a color class for the gray name call method input code
1 UIColor *gray = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];2 self.view.backgroundColor = gray;
4. The test diagram is as follows:
5. Analyze the inserted code
Objective-C is the language of the face object, so
Target: first-class citizens in the Objective-C world
UIColor is a color-related code. It is a color-related object. UIColor is only
Represents a categoryIs not a specific color.
Indicates that an Object of a category is called a CLass (Object) CLass Object.
Only classes do not work. We need a specific object.
The specific Object is called an Instance (Object) Instance Object.
Now we need to use UIColor-the specific color is also called
Instantiation
How to instantiate it? Object calls to methods are called Instantiation.
Objects can call MethodsBoth Class Object and instance object can call methods. class objects can be instantiated by calling methods.
This is a simple example of a specific color of the object method.
Instance Object of the Class Object UIColor
UIColor * gray
UIColor indicates the type of the name.
The name is gary.
* Indicates an object.
Not all things are objects.
Finally, call the Class Object method to obtain an instance object.
This gives you an instantiated color.