IOS Custom Controls

Source: Internet
Author: User

For a simple introduction to the use of Uitoolbar,uinavigationcontroller,uinavigationbar,uibarbuttonitem in iOS7, after searching for information made some of the following collections

----------------------------Uibarbuttonitem----------------------------

1:uibarbuttonitem Hidden Way

[Self.btnpunctuation setwidth:0];

2:uibarbuttonitem gets the frame in the parent view is equivalent to converting Uibarbuttonitem to

Uiview12uibarbuttonitem *barbuttonitem = (Uibarbuttonitem *) sender; UIView *targetview = (UIView *) [Barbuttonitem performselector: @selector (view)];

3: Set custom fonts and system Self.title to keep the style exactly the same.

UIButton *titlebutton = [UIButton buttonwithtype:uibuttontypecustom]; [Titlebutton Setbackgroundcolor:[uicolor Clearcolor]; [Titlebutton setframe: (CGRect) {0,0,100,44}]; [Titlebutton Setcontentedgeinsets:uiedgeinsetsmake (-2, 0, 0, 0)]; [Titlebutton settitle:@ "social activities" forstate:uicontrolstatenormal]; [Titlebutton.titlelabel Setfont:[uifont boldsystemfontofsize:20]; [Titlebutton.titlelabel Setshadowoffset: (cgsize) {0,-1}]; [Self.navigationitem Settitleview:titlebutton];

----------------------------Uibarbuttonitem--------------------------


------------------------------Uinavigationbar-------------------------

1: How to modify the navigation controller background picture (IOS5 above)

[[Uinavigationbar appearance] Setbackgroundimage:image Forbarmetrics:uibarmetricsdefault];

Note: You can set the global control initialization appearance through appearance. However, after the initialization is successful, there are individual style requirements that may be modified in the same way.

The standard height of the Uinavigationbar is 44, and the effect of the background + shadow can be achieved by 44+x before iOS7. From iOS7 onwards. IOS7 redefined the Uinavigationbar standard, Its height can be extended to the status bar. So the height of 44+20 is equal to 64.

And the new specification that just said 44+x way no longer applies to Ios7,ios7 is 64+1. The background and shadows will be set individually, with the following code:

IOS7 New background picture setting method height must be 64[self.navigationcontroller.navigationbar setbackgroundimage:[uiimage imagenamed:@ "Toolbar_ Background_ios7test "] forbarposition:uibarpositiontopattached barmetrics:uibarmetricsdefault];//ios7 Shadows need to be set separately Uicolor Clearcolor is to remove the field 1 pixel shadow [Self.navigationController.navigationBar setshadowimage:[uiimage Help_imagewithcolor: [Uicolor Clearcolor]];

2: Set the translucent background effect for Uinavigationbar:

[Self.navigationController.navigationBar Settranslucent:yes];

Note: The translucent property of Uinavigationbar generated by default in IOS7 is yes. Automatically adds matte blur effects.

3: Change the background color of Uinavigationbar (above iOS7)

[[Uinavigationbar appearance] Setbartintcolor:[uicolor Redcolor]];

----------------------------Uinavigationbar--------------------------------


------------------------Uinavigationcontroller-------------------------- ---

1: Modify the height of the Uinavigationcontroller

[Self.navigationController.navigationBar Setframe:cgrectmake (0,20, 320, 60)];

2: How to activate Uinavigationcontrollerdelegate

Self.navigationController.delegate =self;

3: Set the default for Uinavigationcontroller

Navigationbar here are just a few ideas:

Inheritance: Uinavigationcontroller later rewrite the following two methods:

-(ID) Initwithrootviewcontroller: (Uiviewcontroller *) rootviewcontroller{self = [Super Initwithrootviewcontroller:    Rootviewcontroller];    [Self base_backaction_initnavigationbar:rootviewcontroller]; return self;} -(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{[Super Pushviewcontroller:    Viewcontroller animated:animated]; [Self base_backaction_initnavigationbar:viewcontroller];}

------------------------Uinavigationcontroller-------------------------- ---


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.