Five minutes, use the Cocoaui library to build my interface in the mainstream iOS app

Source: Internet
Author: User

  This project is based on the daily Group purchase project, in the previous article said!

First introduced some cocoaui, is a domestic programmer to do open source open source system, the purpose is to simplify the iOS layout! Official address: Www.cocoaui.com,github Address: Https://github.com/ideawu/cocoaui

We use XML to define the layout interface, in fact, is the traditional HTML + CSS definition interface, most people have experience in page layout, the iOS layout is easy to start and fast! Let's look at the interface we want to do first:

  

  We define this interface according to the HTML+CSS format:  

<Div>    <style>. headdiv {width:100%;        }. divstyle{width:100%;        Height:auto;        Border-bottom:1 solid #eee;        Background: #fff;        Vertical-align:middle;        }. subdivstyle {height:auto;        Border:1 solid #eee;        height:40px;        Background: #fff;        }. textstyle{Float:left;        height:40px;        Valign:middle;        }. Btnstyle {background: #EDA67B;        width:80%;        height:50px;        Float:center; }            </style>        <DivID= "Headcontent"class= "Headdiv">        <imgID= "Profileheader"style= "width:80px;height:80px;float:center;margin:10px;"src= "Default_head.png" />    </Div>        <DivID= "Mywashcar"class= "Subdivstyle"style= "width:50%;height:80px;">        <imgstyle= "Margin:10px;width:50px;height:50px;valign:middle;"src= "Ic_mt_coupon" />        <spantype= "text"class= "TextStyle" >Consumer Volume</span>    </Div>    <DivID= "Mycoupon"class= "Subdivstyle"style= "width:100%;height:80px;">        <imgstyle= "Margin:10px;width:50px;height:50px;valign:middle"src= "Ic_user_main_favorite.png" />        <spanclass= "TextStyle"style= "Vertical-align:middle;" >My collection</span>    </Div>        <DivID= "MyCar"class= "Divstyle">        <imgstyle= "margin:10px"src= "Myfollow.png" />        <spantype= "text"class= "TextStyle">My order</span>        <imgstyle= "float:right;margin:10px;"src= "Ic_arrow.png" />    </Div>            <DivID= "Mymsg"class= "Divstyle">        <imgstyle= "margin:10px"src= "Mylike.png" />        <spanclass= "TextStyle">My comments</span>        <imgstyle= "float:right;margin:10px;"src= "Ic_arrow.png" />    </Div>    <DivID= "Myversion"class= "Divstyle">        <imgstyle= "margin:10px"src= "Moreitems_version.png" />        <spantype= "text"class= "TextStyle">Version update</span>        <imgstyle= "float:right;margin:10px;"src= "Ic_arrow.png" />    </Div>        </Div>

  Place it in the project by naming it a profile.xml file. The format is not the same as the normal HTML+CSS interface! Most HTML tags and CSS properties are supported!

Then introduce the Profile.xml file in Profileviewcontroller: The code is as follows:

-(void) viewdidload{    [Super Viewdidload];        [Self initsystembtn];            root = [IView namedview:@ "Profile.xml"];    [Self addiviewrow:root];    [Self reload];            [Self initevent];}

  Click on the avatar needs to go to modify the player information interface, need to monitor the avatar's Click event:

-(void) initevent{    typeof(self) me = self ;     *profileheader = (IImage *) [root Getviewbyid:@ "profileheader"];    [Profileheader Addevent:ieventclick Handler:^ (ieventtype type,iview *view) {        [me gotoprofileedit];    }] ;}

   is not very simple to define an interface!

Add

1: Support for Sdwebimage, IImage (Uiimageview's re-encapsulation) exposed the Uiimageview interface, can be conveniently used sdwebimage, start is not supported, and the author communicated a bit, exposed this interface!

2: Support for pull-up refresh and drop-down loading. There are examples of evidence: Http://www.cocoaui.com/docs/api/IRefreshControl

3: Support for WebView! There is no support for WebView in the control, if you need to embed webview in the page you need to create it dynamically!

4: Support for radio and Checkboxes is not currently supported and needs to be created dynamically, but very easy!

5: Because many apps need the end, the XML file layout can be ported directly below the mobile side!

Five minutes, use the Cocoaui library to build my interface in the mainstream iOS app

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.