Basic properties of UIView in iOS 1

Source: Internet
Author: User
<span id="Label3"></p><pre><span style="color: #000000;"><span style="color: #000000;">@interface appdelegate () @end @implementation appdelegate</span></span>-(BOOL) application: (uiapplication *) application didfinishlaunchingwithoptions: (nsdictionary *<span style="color: #000000;"><span style="color: #000000;">) launchoptions {</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Uiweindow application window for displaying content to users</span></span>Self.window =<span style="color: #000000;"><span style="color: #000000;">[[[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">CREATE VIEW</span></span>UIView *redview = [[UIView alloc] initwithframe:cgrectmake (<span style="color: #800080;"><span style="color: #800080;"></span> -</span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">)]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Set Background color</span></span>Redview.backgroundcolor=<span style="color: #000000;"><span style="color: #000000;">[uicolor redcolor]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Add to Parent control</span></span><span style="color: #000000;"><span style="color: #000000;">[self.window addsubview:redview]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">One view has only one parent view</span></span>UIView *grayview = [[UIView alloc] initwithframe:cgrectmake (<span style="color: #800080;"><span style="color: #800080;"></span> -</span>,<span style="color: #800080;"><span style="color: #800080;"></span> $</span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">)]; UIView</span></span>*greenview = [[UIView alloc] initwithframe:cgrectmake (<span style="color: #800080;"><span style="color: #800080;"></span> about</span>,<span style="color: #800080;"><span style="color: #800080;"></span> $</span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">)]; [self.window addsubview:greenview]; Greenview.backgroundcolor</span></span>=<span style="color: #000000;"><span style="color: #000000;">[uicolor greencolor]; Grayview.backgroundcolor</span></span>=<span style="color: #000000;"><span style="color: #000000;">[uicolor graycolor]; [redview addsubview:grayview]; [self.window addsubview:grayview]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Freeing Memory</span></span><span style="color: #000000;"><span style="color: #000000;">[redview release]; [grayview release]; [greenview release]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">important attributes of UIView</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">1.backgroundColor Background Color</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">2.hidden display recessive</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">control the explicit implicit of the view, default to No</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">3.alpha transparency, Control The transparency of the view, value range 0.0-1.0</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">4.superview Get parent View</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">5.subvievs Get child views, manage them with arrays, add the sub-views as ordered, add the order corresponding to the position of the array elements</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">6.tag tag, uniquely labeled specified view</span></span>[self.window viewwithtag:<span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">You can also get the child by using the word view</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">UIView *lase = [self.window subviews].lastobject; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Override point for customization after application Launch.</span></span>Self.window.backgroundColor =<span style="color: #000000;"><span style="color: #000000;">[uicolor whitecolor]; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">set the background color of a window</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">let UIWindow become the main window of the program, and the visual</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">[self.window makekeyandvisible];</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">return</span></span><span style="color: #000000;"><span style="color: #000000;">YES;}</span></span></pre><p><p></p></p><p><p>Basic properties of UIView in iOS 1</p></p></span>

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.