[IPhone Development] development notes custom navigation controller Style

Source: Internet
Author: User

[Super
Viewdidload];


// Do any additional setup after loading the view from Its nib.


// Create the view of leftbarbutton of navigationcontroller


Uiview * leftbarview = [[uiview
Alloc] initwithframe: cgrectmake (0,
0,100,
44)];


// Create a homepage button


// Button position, button icon, button background color, button transparent, view global refresh disabled, append Action event


Uibutton * homebutton = [[uibutton
Alloc] initwithframe: cgrectmake (0,
0, 50,
44)];

[Homebutton
Setimage: [uiimage
Imagenamed: @ "title_home_selected.png"]
Forstate: uicontrolstatenormal];

[Homebutton
Setbackgroundcolor: [uicolor
Clearcolor];

Homebutton. opaque =
No;

Homebutton. clearscontextbeforedrawing =
No;

[Homebutton
Addtarget: Self
Action: @ selector (submitaction :)
Forcontrolevents: uicontroleventtouchupinside];


// Create a new button


Uibutton * composebutton = [[uibutton
Alloc] initwithframe: cgrectmake (55,
0, 50,
44)];

[Composebutton
Setimage: [uiimage
Imagenamed: @ "title_new_selected.png"]
Forstate: uicontrolstatenormal];

[Composebutton
Setbackgroundcolor: [uicolor
Clearcolor];

Composebutton. opaque =
No;

Composebutton. clearscontextbeforedrawing =
No;

[Composebutton
Addtarget: Self
Action: @ selector (submitaction :)
Forcontrolevents: uicontroleventtouchupinside];


// Add the Home button and new button to the view

[Leftbarview
Addsubview: homebutton];

[Leftbarview
Addsubview: composebutton];


// Create the item of the leftbarbutton of navigationcontroller and assign a value to it


Uibarbuttonitem * leftbtn = [uibarbuttonitem
Alloc] initwithcustomview: leftbarview];


Self. navigationitem. leftbarbuttonitem = leftbtn;

[Leftbtn
Release];

[Homebutton
Release];

[Composebutton
Release];

[Leftbarview
Release];


Uibutton * refreshbutton = [[uibutton
Alloc] initwithframe: cgrectmake (50,
0, 50,
44)];

[Refreshbutton
Setimage: [uiimage
Imagenamed: @ "title_reload_selected.png"]
Forstate: uicontrolstatenormal];

[Refreshbutton
Setbackgroundcolor: [uicolor
Clearcolor];

Refreshbutton. opaque =
No;

Refreshbutton. clearscontextbeforedrawing =
No;

[Refreshbutton
Addtarget: Self
Action: @ selector (submitaction :)
Forcontrolevents: uicontroleventtouchupinside];


// [Refreshbutton addtarget: Self action: @ selector (submitaction :) forcontrolevents: uicontrolevent];


Uibarbuttonitem * rightbtn = [uibarbuttonitem
Alloc] initwithcustomview: refreshbutton];


Self. navigationitem. rightbarbuttonitem = rightbtn;

[Rightbtn
Release];

[Refreshbutton
Release];

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.