Beginner Ios-uiview

Source: Internet
Author: User

I. Create a UIView

First step: Create

First look at the inheritance relationship, and then find this class has its own initialization method

UIView *view = [[UIView alloc] Initwithframe:cgrectmake (125, 125, 200, 200)];

Step Two: Set the background color by default is transparent

View.backgroundcolor = [Uicolor Cyancolor];

Step Three: Display the view on the window

[Self.window Addsubview:view];

The parent view manages its own child views through an array

Fourth Step: Release

[View release];

Because the parent view is placed into an array for management, the reference count +1,release, so we can add the view and then release the object, offsetting the resulting +1 of the alloc;

Two. Summary of knowledge points

1. A view has a parent view, but can have multiple child views

2. The coordinate starting point of the child view is relative to the 0,0 position of the parent view

3. Parent view can manage hierarchical relationships

[Self.window Bringsubviewtofront:view2];

[Self.window SENDSUBVIEWTOBACK:VIEW3];

4. Setting transparency

View3.alpha = 0.1;//Transparency (Transparency range 0.0 ~ 1.0, default is 1.0)

Beginner Ios-uiview

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.