Lesson 2 change the background color and background color

Source: Internet
Author: User

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.

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.