Customizable navigation bar feature case iOS project source code

Source: Internet
Author: User

Customizable Navigationitem, when we use the system to set Navigationitem's Leftitem or Rightitem, we will find that the item position will be biased (left side to right, left to right). When you set Navigationitem Titleview, you will see that the picture is stretched. So I made a simple package of the system Setup method, which can conveniently set the Navigationitem Leftitem,titleview,rightitem and can control the offset of item independently.

:

    • <ignore_js_op>


How to use:


First, the Custombaritem folder in the demo will be added to the project.

Second, in the file to be set to add the header file #import "Uinavigationitem+customitem.h"

Third, set

1. Set item by text
[Self.navigationitem setitemwithtitle:@ "Custom Item" Textcolor:[uicolor Redcolor] fontsize:16 Itemtype:center];
Parameter description: ①, text content ②, text color ③, font size
④, item format left corresponds to Leftitem center Titleview right corresponds to Rightitem

2. Set item by picture
[Self.navigationitem setitemwithimage:@ "Test1.png" Size:cgsizemake (48/2, 26/2) itemtype:left];
Parameter description: ①, picture name ②, picture size ③, ibid.

3. Add a click event for item
1, 22 sets of methods will return a Custombaritem instance, get this instance to add the event:
Custombaritem *rightitem = [Self.navigationitem setitemwithimage:@ "Test.png" Size:cgsizemake (39/2, 40/2) ItemType: Right];
[Rightitem addtarget:self selector: @selector (search) Event: (UIControlEventTouchUpInside)];

4. Set the item offset
The same 3 get the Custombaritem instance and set it up.
[Rightitem setoffset:10];//the larger the value, the Leftitem the more left Rightitem the right default value is 10

5. Set item size when item is set with text
[Rightitem settitleviewsize:cgsizemake (width, height)];

Detailed Description: http://ios.662p.com/thread-2294-1-1.html

Customizable navigation bar feature case iOS project source code

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.