├── .DS_Store
├── README.md
├── XTNavigationItemDemo.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ ├── chenzhen.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
│ │ └── cz.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── chenzhen.xcuserdatad
│ └── xcschemes
│ │ └── xcschememanagement.plist
│ └── cz.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ └── xcschememanagement.plist
└── XTNavigationItemDemo
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
├── AppIcon.appiconset
│ └── Contents.json
├── Contents.json
├── back.imageset
│ ├── Contents.json
│ ├── back@2x.png
│ └── back@3x.png
├── mine-sun-icon.imageset
│ ├── Contents.json
│ ├── mine-sun-icon@2x.png
│ └── mine-sun-icon@3x.png
├── nav_coin_icon_click.imageset
│ ├── Contents.json
│ ├── nav_coin_icon_click@2x.png
│ └── nav_coin_icon_click@3x.png
├── navigationButtonReturnClick.imageset
│ ├── Contents.json
│ ├── navigationButtonReturnClick@2x.png
│ └── navigationButtonReturnClick@3x.png
├── shuju.imageset
│ ├── Contents.json
│ ├── shuju@2x.png
│ └── shuju@3x.png
└── tixing.imageset
│ ├── Contents.json
│ ├── tixing@2x.png
│ └── tixing@3x.png
├── Base.lproj
├── LaunchScreen.storyboard
└── Main.storyboard
├── Demo1ViewController.h
├── Demo1ViewController.m
├── Demo2ViewController.h
├── Demo2ViewController.m
├── Disqus.png
├── Info.plist
├── UINavigationBar
├── .DS_Store
├── NSObject+SXRuntime.h
├── NSObject+SXRuntime.m
├── UINavigationBar+SXFixSpace.h
├── UINavigationBar+SXFixSpace.m
├── UINavigationConfig.h
├── UINavigationConfig.m
├── UINavigationController+SXFixSpace.h
├── UINavigationController+SXFixSpace.m
├── UINavigationItem+SXFixSpace.h
└── UINavigationItem+SXFixSpace.m
├── UIViewController+BarButton.h
├── UIViewController+BarButton.m
├── ViewController.h
├── ViewController.m
└── main.m
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/.DS_Store
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # XTNavigationItemDemo
2 | 导航栏按钮的封装,使用方便简单,且适配了iOS11。
3 |
4 |
5 | 借鉴了https://github.com/spicyShrimp/UINavigation-SXFixSpace 对其进行了一点封装
6 |
7 |
8 | ```
9 | // 一行代码设置title
10 |
11 | [self setNavTitle:@"首页"];
12 | [self setNavTitle:@"btn1" withAction:@selector(btn1Action)];
13 | [self setNavTitle:@"第一页" withColor:[UIColor blackColor]];
14 |
15 | // 设置左右导航栏
16 | [self addLeftBarButtonWithImage:[UIImage imageNamed:@"navigationButtonReturnClick"] action:@selector(backAction)];
17 |
18 | [self addRightTwoBarButtonsWithFirstImage:[UIImage imageNamed:@"mine-sun-icon"] firstAction:@selector(action1) secondImage:[UIImage imageNamed:@"nav_coin_icon_click"] secondAction:@selector(doneAction)];
19 |
20 | ```
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 48;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 21DA0A7D1FB11C73008145E1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 21DA0A7C1FB11C73008145E1 /* AppDelegate.m */; };
11 | 21DA0A801FB11C73008145E1 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 21DA0A7F1FB11C73008145E1 /* ViewController.m */; };
12 | 21DA0A831FB11C73008145E1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 21DA0A811FB11C73008145E1 /* Main.storyboard */; };
13 | 21DA0A851FB11C73008145E1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 21DA0A841FB11C73008145E1 /* Assets.xcassets */; };
14 | 21DA0A881FB11C73008145E1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 21DA0A861FB11C73008145E1 /* LaunchScreen.storyboard */; };
15 | 21DA0A8B1FB11C73008145E1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 21DA0A8A1FB11C73008145E1 /* main.m */; };
16 | 21DA0A931FB11C8E008145E1 /* Demo1ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 21DA0A921FB11C8E008145E1 /* Demo1ViewController.m */; };
17 | 21DA0A9D1FB14635008145E1 /* UIViewController+BarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 21DA0A9C1FB14635008145E1 /* UIViewController+BarButton.m */; };
18 | 21DA0AAF1FB235D0008145E1 /* Demo2ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 21DA0AAE1FB235D0008145E1 /* Demo2ViewController.m */; };
19 | 21DA0AB41FB23ED4008145E1 /* Disqus.png in Resources */ = {isa = PBXBuildFile; fileRef = 21DA0AB31FB23ED4008145E1 /* Disqus.png */; };
20 | 82A5BA1C20C5FCEA00FF21DF /* UINavigationConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A5BA1420C5FCEA00FF21DF /* UINavigationConfig.m */; };
21 | 82A5BA1D20C5FCEA00FF21DF /* NSObject+SXRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A5BA1520C5FCEA00FF21DF /* NSObject+SXRuntime.m */; };
22 | 82A5BA1E20C5FCEA00FF21DF /* UINavigationItem+SXFixSpace.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A5BA1920C5FCEA00FF21DF /* UINavigationItem+SXFixSpace.m */; };
23 | 82A5BA1F20C5FCEA00FF21DF /* UINavigationController+SXFixSpace.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A5BA1A20C5FCEA00FF21DF /* UINavigationController+SXFixSpace.m */; };
24 | 82A5BA2020C5FCEA00FF21DF /* UINavigationBar+SXFixSpace.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A5BA1B20C5FCEA00FF21DF /* UINavigationBar+SXFixSpace.m */; };
25 | /* End PBXBuildFile section */
26 |
27 | /* Begin PBXFileReference section */
28 | 21DA0A781FB11C73008145E1 /* XTNavigationItemDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XTNavigationItemDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 21DA0A7B1FB11C73008145E1 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
30 | 21DA0A7C1FB11C73008145E1 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
31 | 21DA0A7E1FB11C73008145E1 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
32 | 21DA0A7F1FB11C73008145E1 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
33 | 21DA0A821FB11C73008145E1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
34 | 21DA0A841FB11C73008145E1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
35 | 21DA0A871FB11C73008145E1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
36 | 21DA0A891FB11C73008145E1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
37 | 21DA0A8A1FB11C73008145E1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
38 | 21DA0A911FB11C8E008145E1 /* Demo1ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Demo1ViewController.h; sourceTree = ""; };
39 | 21DA0A921FB11C8E008145E1 /* Demo1ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Demo1ViewController.m; sourceTree = ""; };
40 | 21DA0A9B1FB14635008145E1 /* UIViewController+BarButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BarButton.h"; sourceTree = ""; };
41 | 21DA0A9C1FB14635008145E1 /* UIViewController+BarButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BarButton.m"; sourceTree = ""; };
42 | 21DA0AAD1FB235D0008145E1 /* Demo2ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Demo2ViewController.h; sourceTree = ""; };
43 | 21DA0AAE1FB235D0008145E1 /* Demo2ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Demo2ViewController.m; sourceTree = ""; };
44 | 21DA0AB31FB23ED4008145E1 /* Disqus.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Disqus.png; sourceTree = ""; };
45 | 82A5BA1220C5FCEA00FF21DF /* UINavigationConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UINavigationConfig.h; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationConfig.h"; sourceTree = ""; };
46 | 82A5BA1320C5FCEA00FF21DF /* NSObject+SXRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSObject+SXRuntime.h"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/NSObject+SXRuntime.h"; sourceTree = ""; };
47 | 82A5BA1420C5FCEA00FF21DF /* UINavigationConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UINavigationConfig.m; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationConfig.m"; sourceTree = ""; };
48 | 82A5BA1520C5FCEA00FF21DF /* NSObject+SXRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSObject+SXRuntime.m"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/NSObject+SXRuntime.m"; sourceTree = ""; };
49 | 82A5BA1620C5FCEA00FF21DF /* UINavigationController+SXFixSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UINavigationController+SXFixSpace.h"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationController+SXFixSpace.h"; sourceTree = ""; };
50 | 82A5BA1720C5FCEA00FF21DF /* UINavigationItem+SXFixSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UINavigationItem+SXFixSpace.h"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationItem+SXFixSpace.h"; sourceTree = ""; };
51 | 82A5BA1820C5FCEA00FF21DF /* UINavigationBar+SXFixSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UINavigationBar+SXFixSpace.h"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationBar+SXFixSpace.h"; sourceTree = ""; };
52 | 82A5BA1920C5FCEA00FF21DF /* UINavigationItem+SXFixSpace.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UINavigationItem+SXFixSpace.m"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationItem+SXFixSpace.m"; sourceTree = ""; };
53 | 82A5BA1A20C5FCEA00FF21DF /* UINavigationController+SXFixSpace.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UINavigationController+SXFixSpace.m"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationController+SXFixSpace.m"; sourceTree = ""; };
54 | 82A5BA1B20C5FCEA00FF21DF /* UINavigationBar+SXFixSpace.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UINavigationBar+SXFixSpace.m"; path = "../../../../Downloads/UINavigation-SXFixSpace-master/UINavigation-SXFixSpace/UINavigationBar+SXFixSpace.m"; sourceTree = ""; };
55 | /* End PBXFileReference section */
56 |
57 | /* Begin PBXFrameworksBuildPhase section */
58 | 21DA0A751FB11C73008145E1 /* Frameworks */ = {
59 | isa = PBXFrameworksBuildPhase;
60 | buildActionMask = 2147483647;
61 | files = (
62 | );
63 | runOnlyForDeploymentPostprocessing = 0;
64 | };
65 | /* End PBXFrameworksBuildPhase section */
66 |
67 | /* Begin PBXGroup section */
68 | 21DA0A6F1FB11C72008145E1 = {
69 | isa = PBXGroup;
70 | children = (
71 | 21DA0A7A1FB11C73008145E1 /* XTNavigationItemDemo */,
72 | 21DA0A791FB11C73008145E1 /* Products */,
73 | );
74 | sourceTree = "";
75 | };
76 | 21DA0A791FB11C73008145E1 /* Products */ = {
77 | isa = PBXGroup;
78 | children = (
79 | 21DA0A781FB11C73008145E1 /* XTNavigationItemDemo.app */,
80 | );
81 | name = Products;
82 | sourceTree = "";
83 | };
84 | 21DA0A7A1FB11C73008145E1 /* XTNavigationItemDemo */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 21DA0AB31FB23ED4008145E1 /* Disqus.png */,
88 | 21DA0A9A1FB1461C008145E1 /* UINavigationBar */,
89 | 21DA0A7B1FB11C73008145E1 /* AppDelegate.h */,
90 | 21DA0A7C1FB11C73008145E1 /* AppDelegate.m */,
91 | 21DA0A9B1FB14635008145E1 /* UIViewController+BarButton.h */,
92 | 21DA0A9C1FB14635008145E1 /* UIViewController+BarButton.m */,
93 | 21DA0A7E1FB11C73008145E1 /* ViewController.h */,
94 | 21DA0A7F1FB11C73008145E1 /* ViewController.m */,
95 | 21DA0A811FB11C73008145E1 /* Main.storyboard */,
96 | 21DA0A841FB11C73008145E1 /* Assets.xcassets */,
97 | 21DA0A861FB11C73008145E1 /* LaunchScreen.storyboard */,
98 | 21DA0A891FB11C73008145E1 /* Info.plist */,
99 | 21DA0A8A1FB11C73008145E1 /* main.m */,
100 | 21DA0A911FB11C8E008145E1 /* Demo1ViewController.h */,
101 | 21DA0A921FB11C8E008145E1 /* Demo1ViewController.m */,
102 | 21DA0AAD1FB235D0008145E1 /* Demo2ViewController.h */,
103 | 21DA0AAE1FB235D0008145E1 /* Demo2ViewController.m */,
104 | );
105 | path = XTNavigationItemDemo;
106 | sourceTree = "";
107 | };
108 | 21DA0A9A1FB1461C008145E1 /* UINavigationBar */ = {
109 | isa = PBXGroup;
110 | children = (
111 | 82A5BA1320C5FCEA00FF21DF /* NSObject+SXRuntime.h */,
112 | 82A5BA1520C5FCEA00FF21DF /* NSObject+SXRuntime.m */,
113 | 82A5BA1820C5FCEA00FF21DF /* UINavigationBar+SXFixSpace.h */,
114 | 82A5BA1B20C5FCEA00FF21DF /* UINavigationBar+SXFixSpace.m */,
115 | 82A5BA1220C5FCEA00FF21DF /* UINavigationConfig.h */,
116 | 82A5BA1420C5FCEA00FF21DF /* UINavigationConfig.m */,
117 | 82A5BA1620C5FCEA00FF21DF /* UINavigationController+SXFixSpace.h */,
118 | 82A5BA1A20C5FCEA00FF21DF /* UINavigationController+SXFixSpace.m */,
119 | 82A5BA1720C5FCEA00FF21DF /* UINavigationItem+SXFixSpace.h */,
120 | 82A5BA1920C5FCEA00FF21DF /* UINavigationItem+SXFixSpace.m */,
121 | );
122 | path = UINavigationBar;
123 | sourceTree = "";
124 | };
125 | /* End PBXGroup section */
126 |
127 | /* Begin PBXNativeTarget section */
128 | 21DA0A771FB11C73008145E1 /* XTNavigationItemDemo */ = {
129 | isa = PBXNativeTarget;
130 | buildConfigurationList = 21DA0A8E1FB11C73008145E1 /* Build configuration list for PBXNativeTarget "XTNavigationItemDemo" */;
131 | buildPhases = (
132 | 21DA0A741FB11C73008145E1 /* Sources */,
133 | 21DA0A751FB11C73008145E1 /* Frameworks */,
134 | 21DA0A761FB11C73008145E1 /* Resources */,
135 | );
136 | buildRules = (
137 | );
138 | dependencies = (
139 | );
140 | name = XTNavigationItemDemo;
141 | productName = XTNavigationItemDemo;
142 | productReference = 21DA0A781FB11C73008145E1 /* XTNavigationItemDemo.app */;
143 | productType = "com.apple.product-type.application";
144 | };
145 | /* End PBXNativeTarget section */
146 |
147 | /* Begin PBXProject section */
148 | 21DA0A701FB11C72008145E1 /* Project object */ = {
149 | isa = PBXProject;
150 | attributes = {
151 | LastUpgradeCheck = 0900;
152 | ORGANIZATIONNAME = sjxt.me;
153 | TargetAttributes = {
154 | 21DA0A771FB11C73008145E1 = {
155 | CreatedOnToolsVersion = 9.0.1;
156 | ProvisioningStyle = Automatic;
157 | };
158 | };
159 | };
160 | buildConfigurationList = 21DA0A731FB11C72008145E1 /* Build configuration list for PBXProject "XTNavigationItemDemo" */;
161 | compatibilityVersion = "Xcode 8.0";
162 | developmentRegion = en;
163 | hasScannedForEncodings = 0;
164 | knownRegions = (
165 | en,
166 | Base,
167 | );
168 | mainGroup = 21DA0A6F1FB11C72008145E1;
169 | productRefGroup = 21DA0A791FB11C73008145E1 /* Products */;
170 | projectDirPath = "";
171 | projectRoot = "";
172 | targets = (
173 | 21DA0A771FB11C73008145E1 /* XTNavigationItemDemo */,
174 | );
175 | };
176 | /* End PBXProject section */
177 |
178 | /* Begin PBXResourcesBuildPhase section */
179 | 21DA0A761FB11C73008145E1 /* Resources */ = {
180 | isa = PBXResourcesBuildPhase;
181 | buildActionMask = 2147483647;
182 | files = (
183 | 21DA0A881FB11C73008145E1 /* LaunchScreen.storyboard in Resources */,
184 | 21DA0A851FB11C73008145E1 /* Assets.xcassets in Resources */,
185 | 21DA0AB41FB23ED4008145E1 /* Disqus.png in Resources */,
186 | 21DA0A831FB11C73008145E1 /* Main.storyboard in Resources */,
187 | );
188 | runOnlyForDeploymentPostprocessing = 0;
189 | };
190 | /* End PBXResourcesBuildPhase section */
191 |
192 | /* Begin PBXSourcesBuildPhase section */
193 | 21DA0A741FB11C73008145E1 /* Sources */ = {
194 | isa = PBXSourcesBuildPhase;
195 | buildActionMask = 2147483647;
196 | files = (
197 | 21DA0A801FB11C73008145E1 /* ViewController.m in Sources */,
198 | 82A5BA1F20C5FCEA00FF21DF /* UINavigationController+SXFixSpace.m in Sources */,
199 | 82A5BA1D20C5FCEA00FF21DF /* NSObject+SXRuntime.m in Sources */,
200 | 21DA0A931FB11C8E008145E1 /* Demo1ViewController.m in Sources */,
201 | 82A5BA1E20C5FCEA00FF21DF /* UINavigationItem+SXFixSpace.m in Sources */,
202 | 21DA0A8B1FB11C73008145E1 /* main.m in Sources */,
203 | 21DA0A7D1FB11C73008145E1 /* AppDelegate.m in Sources */,
204 | 21DA0AAF1FB235D0008145E1 /* Demo2ViewController.m in Sources */,
205 | 82A5BA2020C5FCEA00FF21DF /* UINavigationBar+SXFixSpace.m in Sources */,
206 | 82A5BA1C20C5FCEA00FF21DF /* UINavigationConfig.m in Sources */,
207 | 21DA0A9D1FB14635008145E1 /* UIViewController+BarButton.m in Sources */,
208 | );
209 | runOnlyForDeploymentPostprocessing = 0;
210 | };
211 | /* End PBXSourcesBuildPhase section */
212 |
213 | /* Begin PBXVariantGroup section */
214 | 21DA0A811FB11C73008145E1 /* Main.storyboard */ = {
215 | isa = PBXVariantGroup;
216 | children = (
217 | 21DA0A821FB11C73008145E1 /* Base */,
218 | );
219 | name = Main.storyboard;
220 | sourceTree = "";
221 | };
222 | 21DA0A861FB11C73008145E1 /* LaunchScreen.storyboard */ = {
223 | isa = PBXVariantGroup;
224 | children = (
225 | 21DA0A871FB11C73008145E1 /* Base */,
226 | );
227 | name = LaunchScreen.storyboard;
228 | sourceTree = "";
229 | };
230 | /* End PBXVariantGroup section */
231 |
232 | /* Begin XCBuildConfiguration section */
233 | 21DA0A8C1FB11C73008145E1 /* Debug */ = {
234 | isa = XCBuildConfiguration;
235 | buildSettings = {
236 | ALWAYS_SEARCH_USER_PATHS = NO;
237 | CLANG_ANALYZER_NONNULL = YES;
238 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
240 | CLANG_CXX_LIBRARY = "libc++";
241 | CLANG_ENABLE_MODULES = YES;
242 | CLANG_ENABLE_OBJC_ARC = YES;
243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
244 | CLANG_WARN_BOOL_CONVERSION = YES;
245 | CLANG_WARN_COMMA = YES;
246 | CLANG_WARN_CONSTANT_CONVERSION = YES;
247 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
248 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
249 | CLANG_WARN_EMPTY_BODY = YES;
250 | CLANG_WARN_ENUM_CONVERSION = YES;
251 | CLANG_WARN_INFINITE_RECURSION = YES;
252 | CLANG_WARN_INT_CONVERSION = YES;
253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
254 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
255 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
256 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
257 | CLANG_WARN_STRICT_PROTOTYPES = YES;
258 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
259 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
260 | CLANG_WARN_UNREACHABLE_CODE = YES;
261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
262 | CODE_SIGN_IDENTITY = "iPhone Developer";
263 | COPY_PHASE_STRIP = NO;
264 | DEBUG_INFORMATION_FORMAT = dwarf;
265 | ENABLE_STRICT_OBJC_MSGSEND = YES;
266 | ENABLE_TESTABILITY = YES;
267 | GCC_C_LANGUAGE_STANDARD = gnu11;
268 | GCC_DYNAMIC_NO_PIC = NO;
269 | GCC_NO_COMMON_BLOCKS = YES;
270 | GCC_OPTIMIZATION_LEVEL = 0;
271 | GCC_PREPROCESSOR_DEFINITIONS = (
272 | "DEBUG=1",
273 | "$(inherited)",
274 | );
275 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
276 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
277 | GCC_WARN_UNDECLARED_SELECTOR = YES;
278 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
279 | GCC_WARN_UNUSED_FUNCTION = YES;
280 | GCC_WARN_UNUSED_VARIABLE = YES;
281 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
282 | MTL_ENABLE_DEBUG_INFO = YES;
283 | ONLY_ACTIVE_ARCH = YES;
284 | SDKROOT = iphoneos;
285 | };
286 | name = Debug;
287 | };
288 | 21DA0A8D1FB11C73008145E1 /* Release */ = {
289 | isa = XCBuildConfiguration;
290 | buildSettings = {
291 | ALWAYS_SEARCH_USER_PATHS = NO;
292 | CLANG_ANALYZER_NONNULL = YES;
293 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
294 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
295 | CLANG_CXX_LIBRARY = "libc++";
296 | CLANG_ENABLE_MODULES = YES;
297 | CLANG_ENABLE_OBJC_ARC = YES;
298 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
299 | CLANG_WARN_BOOL_CONVERSION = YES;
300 | CLANG_WARN_COMMA = YES;
301 | CLANG_WARN_CONSTANT_CONVERSION = YES;
302 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
303 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
304 | CLANG_WARN_EMPTY_BODY = YES;
305 | CLANG_WARN_ENUM_CONVERSION = YES;
306 | CLANG_WARN_INFINITE_RECURSION = YES;
307 | CLANG_WARN_INT_CONVERSION = YES;
308 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
309 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
310 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
311 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
312 | CLANG_WARN_STRICT_PROTOTYPES = YES;
313 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
314 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
315 | CLANG_WARN_UNREACHABLE_CODE = YES;
316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
317 | CODE_SIGN_IDENTITY = "iPhone Developer";
318 | COPY_PHASE_STRIP = NO;
319 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
320 | ENABLE_NS_ASSERTIONS = NO;
321 | ENABLE_STRICT_OBJC_MSGSEND = YES;
322 | GCC_C_LANGUAGE_STANDARD = gnu11;
323 | GCC_NO_COMMON_BLOCKS = YES;
324 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
325 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
326 | GCC_WARN_UNDECLARED_SELECTOR = YES;
327 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
328 | GCC_WARN_UNUSED_FUNCTION = YES;
329 | GCC_WARN_UNUSED_VARIABLE = YES;
330 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
331 | MTL_ENABLE_DEBUG_INFO = NO;
332 | SDKROOT = iphoneos;
333 | VALIDATE_PRODUCT = YES;
334 | };
335 | name = Release;
336 | };
337 | 21DA0A8F1FB11C73008145E1 /* Debug */ = {
338 | isa = XCBuildConfiguration;
339 | buildSettings = {
340 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
341 | CODE_SIGN_STYLE = Automatic;
342 | INFOPLIST_FILE = XTNavigationItemDemo/Info.plist;
343 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
344 | PRODUCT_BUNDLE_IDENTIFIER = com.vd.XTNavigationItemDemo;
345 | PRODUCT_NAME = "$(TARGET_NAME)";
346 | TARGETED_DEVICE_FAMILY = "1,2";
347 | };
348 | name = Debug;
349 | };
350 | 21DA0A901FB11C73008145E1 /* Release */ = {
351 | isa = XCBuildConfiguration;
352 | buildSettings = {
353 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
354 | CODE_SIGN_STYLE = Automatic;
355 | INFOPLIST_FILE = XTNavigationItemDemo/Info.plist;
356 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
357 | PRODUCT_BUNDLE_IDENTIFIER = com.vd.XTNavigationItemDemo;
358 | PRODUCT_NAME = "$(TARGET_NAME)";
359 | TARGETED_DEVICE_FAMILY = "1,2";
360 | };
361 | name = Release;
362 | };
363 | /* End XCBuildConfiguration section */
364 |
365 | /* Begin XCConfigurationList section */
366 | 21DA0A731FB11C72008145E1 /* Build configuration list for PBXProject "XTNavigationItemDemo" */ = {
367 | isa = XCConfigurationList;
368 | buildConfigurations = (
369 | 21DA0A8C1FB11C73008145E1 /* Debug */,
370 | 21DA0A8D1FB11C73008145E1 /* Release */,
371 | );
372 | defaultConfigurationIsVisible = 0;
373 | defaultConfigurationName = Release;
374 | };
375 | 21DA0A8E1FB11C73008145E1 /* Build configuration list for PBXNativeTarget "XTNavigationItemDemo" */ = {
376 | isa = XCConfigurationList;
377 | buildConfigurations = (
378 | 21DA0A8F1FB11C73008145E1 /* Debug */,
379 | 21DA0A901FB11C73008145E1 /* Release */,
380 | );
381 | defaultConfigurationIsVisible = 0;
382 | defaultConfigurationName = Release;
383 | };
384 | /* End XCConfigurationList section */
385 | };
386 | rootObject = 21DA0A701FB11C72008145E1 /* Project object */;
387 | }
388 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo.xcodeproj/project.xcworkspace/xcuserdata/chenzhen.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo.xcodeproj/project.xcworkspace/xcuserdata/chenzhen.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/XTNavigationItemDemo.xcodeproj/project.xcworkspace/xcuserdata/cz.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo.xcodeproj/project.xcworkspace/xcuserdata/cz.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/XTNavigationItemDemo.xcodeproj/xcuserdata/chenzhen.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | XTNavigationItemDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo.xcodeproj/xcuserdata/cz.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo.xcodeproj/xcuserdata/cz.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | XTNavigationItemDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/back.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "back@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "back@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | },
22 | "properties" : {
23 | "template-rendering-intent" : "original"
24 | }
25 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/back.imageset/back@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/back.imageset/back@2x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/back.imageset/back@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/back.imageset/back@3x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/mine-sun-icon.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "mine-sun-icon@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "mine-sun-icon@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/mine-sun-icon.imageset/mine-sun-icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/mine-sun-icon.imageset/mine-sun-icon@2x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/mine-sun-icon.imageset/mine-sun-icon@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/mine-sun-icon.imageset/mine-sun-icon@3x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/nav_coin_icon_click.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "nav_coin_icon_click@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "nav_coin_icon_click@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/nav_coin_icon_click.imageset/nav_coin_icon_click@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/nav_coin_icon_click.imageset/nav_coin_icon_click@2x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/nav_coin_icon_click.imageset/nav_coin_icon_click@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/nav_coin_icon_click.imageset/nav_coin_icon_click@3x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/navigationButtonReturnClick.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "navigationButtonReturnClick@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "navigationButtonReturnClick@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/navigationButtonReturnClick.imageset/navigationButtonReturnClick@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/navigationButtonReturnClick.imageset/navigationButtonReturnClick@2x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/navigationButtonReturnClick.imageset/navigationButtonReturnClick@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/navigationButtonReturnClick.imageset/navigationButtonReturnClick@3x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/shuju.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "shuju@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "shuju@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/shuju.imageset/shuju@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/shuju.imageset/shuju@2x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/shuju.imageset/shuju@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/shuju.imageset/shuju@3x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/tixing.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "tixing@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "tixing@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/tixing.imageset/tixing@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/tixing.imageset/tixing@2x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Assets.xcassets/tixing.imageset/tixing@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Assets.xcassets/tixing.imageset/tixing@3x.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Demo1ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Demo1ViewController.h
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Demo1ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Demo1ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Demo1ViewController.m
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import "Demo1ViewController.h"
10 | #import "UIViewController+BarButton.h"
11 | #import "Demo2ViewController.h"
12 |
13 | @interface Demo1ViewController ()
14 |
15 | @end
16 |
17 | @implementation Demo1ViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view.
22 |
23 | self.view.backgroundColor = [UIColor redColor];
24 |
25 |
26 | [self addLeftBarButtonWithImage:[UIImage imageNamed:@"navigationButtonReturnClick"] action:@selector(backAction)];
27 | [self addRightTwoBarButtonsWithFirstImage:[UIImage imageNamed:@"mine-sun-icon"] firstAction:@selector(action1) secondImage:[UIImage imageNamed:@"nav_coin_icon_click"] secondAction:@selector(doneAction)];
28 |
29 | // if (@available(iOS 11.0, *)) {
30 | // self.navigationController.navigationBar.prefersLargeTitles = YES;
31 | // self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAutomatic;
32 | // }
33 |
34 |
35 | // titleView
36 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 180, 20)];
37 | UIImageView *img = [[UIImageView alloc] initWithFrame:view.frame];
38 | img.image = [UIImage imageNamed:@"Disqus.png"];
39 | img.contentMode = UIViewContentModeScaleAspectFit;
40 | // [view setTextAlignment:NSTextAlignmentCenter];
41 | [view addSubview:img];
42 | self.navigationItem.titleView = view;
43 | //
44 | // self.navigationItem.title = @"1234";
45 | }
46 |
47 |
48 | - (void)backAction{
49 | [self.navigationController popViewControllerAnimated:YES];
50 | }
51 |
52 |
53 | - (void) action1{
54 |
55 | NSLog(@"%s",__func__);
56 | Demo2ViewController *d2 = [[Demo2ViewController alloc] init];
57 | [self.navigationController pushViewController:d2 animated:YES];
58 | }
59 |
60 | - (void) doneAction{
61 |
62 | NSLog(@"_______ %s",__func__);
63 |
64 | Demo2ViewController *d2 = [[Demo2ViewController alloc] init];
65 | [self.navigationController pushViewController:d2 animated:YES];
66 | }
67 |
68 |
69 |
70 | - (void)didReceiveMemoryWarning {
71 | [super didReceiveMemoryWarning];
72 | // Dispose of any resources that can be recreated.
73 | }
74 |
75 | /*
76 | #pragma mark - Navigation
77 |
78 | // In a storyboard-based application, you will often want to do a little preparation before navigation
79 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
80 | // Get the new view controller using [segue destinationViewController].
81 | // Pass the selected object to the new view controller.
82 | }
83 | */
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Demo2ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Demo2ViewController.h
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/7.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Demo2ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Demo2ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Demo2ViewController.m
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/7.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import "Demo2ViewController.h"
10 | #import "UIViewController+BarButton.h"
11 |
12 | @interface Demo2ViewController ()
13 |
14 | @end
15 |
16 | @implementation Demo2ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | // Do any additional setup after loading the view.
21 |
22 | self.view.backgroundColor = [UIColor blueColor];
23 |
24 | [self addLeftBarButtonWithImage:[UIImage imageNamed:@"navigationButtonReturnClick"] action:@selector(backAction)];
25 |
26 | [self addRightThreeBarButtonsWithFirstImage:[UIImage imageNamed:@"mine-sun-icon"] firstAction:nil secondImage:[UIImage imageNamed:@"nav_coin_icon_click"] secondAction:nil thirdImage:[UIImage imageNamed:@"shuju"] thirdAction:nil];
27 |
28 |
29 | [self setNavTitle:@"第三页" withColor:[UIColor blackColor]];
30 | }
31 |
32 |
33 |
34 |
35 |
36 |
37 | - (void)didReceiveMemoryWarning {
38 | [super didReceiveMemoryWarning];
39 | // Dispose of any resources that can be recreated.
40 | }
41 |
42 | - (void)backAction{
43 | [self.navigationController popViewControllerAnimated:YES];
44 | }
45 |
46 |
47 | /*
48 | #pragma mark - Navigation
49 |
50 | // In a storyboard-based application, you will often want to do a little preparation before navigation
51 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
52 | // Get the new view controller using [segue destinationViewController].
53 | // Pass the selected object to the new view controller.
54 | }
55 | */
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Disqus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/Disqus.png
--------------------------------------------------------------------------------
/XTNavigationItemDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sjxt/XTNavigationItemDemo/59e4d3a7171e7ac83a6f304c59ab6cc2462bd2c4/XTNavigationItemDemo/UINavigationBar/.DS_Store
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/NSObject+SXRuntime.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+SXRuntime.h
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2017/9/8.
6 | // Copyright © 2017年 None. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSObject (SXRuntime)
12 |
13 | /**
14 | swizzle 类方法
15 |
16 | @param oriSel 原有的方法
17 | @param swiSel swizzle的方法
18 | */
19 | + (void)swizzleClassMethodWithOriginSel:(SEL)oriSel swizzledSel:(SEL)swiSel;
20 |
21 | /**
22 | swizzle 实例方法
23 |
24 | @param oriSel 原有的方法
25 | @param swiSel swizzle的方法
26 | */
27 | + (void)swizzleInstanceMethodWithOriginSel:(SEL)oriSel swizzledSel:(SEL)swiSel;
28 |
29 | /**
30 | 判断方法是否在子类里override了
31 |
32 | @param cls 传入要判断的Class
33 | @param sel 传入要判断的Selector
34 | @return 返回判断是否被重载的结果
35 | */
36 | - (BOOL)isMethodOverride:(Class)cls selector:(SEL)sel;
37 |
38 | /**
39 | 判断当前类是否在主bundle里
40 |
41 | @param cls 出入类
42 | @return 返回判断结果
43 | */
44 | + (BOOL)isMainBundleClass:(Class)cls;
45 |
46 | /**
47 | 动态创建绑定selector的类
48 | tip:每当无法找到selectorcrash转发过来的所有selector都会追加到当前Class上
49 |
50 | @param aSelector 传入selector
51 | @return 返回创建的类
52 | */
53 | + (Class)addMethodToStubClass:(SEL)aSelector;
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/NSObject+SXRuntime.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+SXRuntime.m
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2017/9/8.
6 | // Copyright © 2017年 None. All rights reserved.
7 | //
8 |
9 | #import "NSObject+SXRuntime.h"
10 | #import
11 |
12 | char * const kProtectCrashProtectorName = "kProtectCrashProtector";
13 |
14 | void ProtectCrashProtected(id self, SEL sel) {
15 | }
16 |
17 | @implementation NSObject (SXRuntime)
18 |
19 | // MARK: Util
20 | + (void)swizzleClassMethodWithOriginSel:(SEL)oriSel swizzledSel:(SEL)swiSel {
21 | Class cls = object_getClass(self);
22 |
23 | Method originAddObserverMethod = class_getClassMethod(cls, oriSel);
24 | Method swizzledAddObserverMethod = class_getClassMethod(cls, swiSel);
25 |
26 | [self swizzleMethodWithOriginSel:oriSel oriMethod:originAddObserverMethod swizzledSel:swiSel swizzledMethod:swizzledAddObserverMethod class:cls];
27 | }
28 |
29 | + (void)swizzleInstanceMethodWithOriginSel:(SEL)oriSel swizzledSel:(SEL)swiSel {
30 | Method originAddObserverMethod = class_getInstanceMethod(self, oriSel);
31 | Method swizzledAddObserverMethod = class_getInstanceMethod(self, swiSel);
32 |
33 | [self swizzleMethodWithOriginSel:oriSel oriMethod:originAddObserverMethod swizzledSel:swiSel swizzledMethod:swizzledAddObserverMethod class:self];
34 | }
35 |
36 | + (void)swizzleMethodWithOriginSel:(SEL)oriSel
37 | oriMethod:(Method)oriMethod
38 | swizzledSel:(SEL)swizzledSel
39 | swizzledMethod:(Method)swizzledMethod
40 | class:(Class)cls {
41 | BOOL didAddMethod = class_addMethod(cls, oriSel, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
42 |
43 | if (didAddMethod) {
44 | class_replaceMethod(cls, swizzledSel, method_getImplementation(oriMethod), method_getTypeEncoding(oriMethod));
45 | } else {
46 | method_exchangeImplementations(oriMethod, swizzledMethod);
47 | }
48 | }
49 |
50 | + (Class)addMethodToStubClass:(SEL)aSelector {
51 | Class ProtectCrashProtector = objc_getClass(kProtectCrashProtectorName);
52 |
53 | if (!ProtectCrashProtector) {
54 | ProtectCrashProtector = objc_allocateClassPair([NSObject class], kProtectCrashProtectorName, sizeof([NSObject class]));
55 | objc_registerClassPair(ProtectCrashProtector);
56 | }
57 |
58 | class_addMethod(ProtectCrashProtector, aSelector, (IMP)ProtectCrashProtected, "v@:");
59 | return ProtectCrashProtector;
60 | }
61 |
62 | - (BOOL)isMethodOverride:(Class)cls selector:(SEL)sel {
63 | IMP clsIMP = class_getMethodImplementation(cls, sel);
64 | IMP superClsIMP = class_getMethodImplementation([cls superclass], sel);
65 |
66 | return clsIMP != superClsIMP;
67 | }
68 |
69 | + (BOOL)isMainBundleClass:(Class)cls {
70 | return cls && [[NSBundle bundleForClass:cls] isEqual:[NSBundle mainBundle]];
71 | }
72 |
73 | @end;
74 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationBar+SXFixSpace.h:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationBar+SXFixSpace.h
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UINavigationBar (SXFixSpace)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationBar+SXFixSpace.m:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationBar+SXFixSpace.m
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import "UINavigationBar+SXFixSpace.h"
10 | #import "UINavigationConfig.h"
11 | #import "NSObject+SXRuntime.h"
12 |
13 | #ifndef sx_deviceVersion
14 | #define sx_deviceVersion [[[UIDevice currentDevice] systemVersion] floatValue]
15 | #endif
16 |
17 | @implementation UINavigationBar (SXFixSpace)
18 |
19 | +(void)load {
20 | static dispatch_once_t onceToken;
21 | dispatch_once(&onceToken, ^{
22 | [self swizzleInstanceMethodWithOriginSel:@selector(layoutSubviews)
23 | swizzledSel:@selector(sx_layoutSubviews)];
24 | });
25 | }
26 |
27 | -(void)sx_layoutSubviews{
28 | [self sx_layoutSubviews];
29 | if (sx_deviceVersion >= 11 && ![UINavigationConfig shared].sx_disableFixSpace) {//需要调节
30 | // self.layoutMargins = UIEdgeInsetsZero;
31 | CGFloat space = [UINavigationConfig shared].sx_defaultFixSpace;
32 | for (UIView *subview in self.subviews) {
33 | if ([NSStringFromClass(subview.class) containsString:@"ContentView"]) {
34 | subview.layoutMargins = UIEdgeInsetsMake(0, space, 0, space);//可修正iOS11之后的偏移
35 | break;
36 | }
37 | }
38 | }
39 | }
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationConfig.h:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationConfig.h
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface UINavigationConfig : NSObject
13 |
14 | + (instancetype)shared;//
15 |
16 | - (instancetype)init NS_UNAVAILABLE;
17 | + (instancetype)new NS_UNAVAILABLE;
18 |
19 | @property(nonatomic, assign)CGFloat sx_defaultFixSpace;//item距离两端的间距,默认为0
20 | @property(nonatomic, assign)BOOL sx_disableFixSpace;//是否禁止使用修正,默认为NO
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationConfig.m:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationConfig.m
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import "UINavigationConfig.h"
10 |
11 | @implementation UINavigationConfig
12 |
13 | +(instancetype)shared {
14 | static UINavigationConfig *config;
15 | static dispatch_once_t onceToken;
16 | dispatch_once(&onceToken, ^{
17 | config = [[self alloc] init];
18 | });
19 | return config;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationController+SXFixSpace.h:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationController+SXFixSpace.h
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UINavigationController (SXFixSpace)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationController+SXFixSpace.m:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationController+SXFixSpace.m
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import "UINavigationController+SXFixSpace.h"
10 | #import "UINavigationConfig.h"
11 | #import
12 | #import "NSObject+SXRuntime.h"
13 |
14 | #ifndef sx_deviceVersion
15 | #define sx_deviceVersion [[[UIDevice currentDevice] systemVersion] floatValue]
16 | #endif
17 |
18 | static BOOL sx_tempDisableFixSpace = NO;
19 |
20 | @implementation UINavigationController (SXFixSpace)
21 |
22 | +(void)load {
23 | static dispatch_once_t onceToken;
24 | dispatch_once(&onceToken, ^{
25 | [self swizzleInstanceMethodWithOriginSel:@selector(viewWillAppear:)
26 | swizzledSel:@selector(sx_viewWillAppear:)];
27 |
28 | [self swizzleInstanceMethodWithOriginSel:@selector(viewWillDisappear:)
29 | swizzledSel:@selector(sx_viewWillDisappear:)];
30 | //FIXME:修正iOS11之后push或者pop动画为NO 系统不主动调用UINavigationBar的layoutSubviews方法
31 | if (sx_deviceVersion >= 11) {
32 | [self swizzleInstanceMethodWithOriginSel:@selector(pushViewController:animated:)
33 | swizzledSel:@selector(sx_pushViewController:animated:)];
34 |
35 | [self swizzleInstanceMethodWithOriginSel:@selector(popViewControllerAnimated:)
36 | swizzledSel:@selector(sx_popViewControllerAnimated:)];
37 |
38 | [self swizzleInstanceMethodWithOriginSel:@selector(popToViewController:animated:)
39 | swizzledSel:@selector(sx_popToViewController:animated:)];
40 |
41 | [self swizzleInstanceMethodWithOriginSel:@selector(popToRootViewControllerAnimated:)
42 | swizzledSel:@selector(sx_popToRootViewControllerAnimated:)];
43 |
44 | [self swizzleInstanceMethodWithOriginSel:@selector(setViewControllers:animated:)
45 | swizzledSel:@selector(sx_setViewControllers:animated:)];
46 | }
47 | });
48 | }
49 |
50 |
51 | -(void)sx_viewWillAppear:(BOOL)animated {
52 | if ([self isKindOfClass:[UIImagePickerController class]]) {
53 | sx_tempDisableFixSpace = [UINavigationConfig shared].sx_disableFixSpace;
54 | [UINavigationConfig shared].sx_disableFixSpace = YES;
55 | }
56 |
57 | [self sx_viewWillAppear:animated];
58 | }
59 |
60 | -(void)sx_viewWillDisappear:(BOOL)animated{
61 | if ([self isKindOfClass:[UIImagePickerController class]]) {
62 | [UINavigationConfig shared].sx_disableFixSpace = sx_tempDisableFixSpace;
63 | }
64 | [self sx_viewWillDisappear:animated];
65 | }
66 |
67 | //FIXME:修正iOS11之后push或者pop动画为NO 系统不主动调用UINavigationBar的layoutSubviews方法
68 | -(void)sx_pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
69 | [self sx_pushViewController:viewController animated:animated];
70 | if (![UINavigationConfig shared].sx_disableFixSpace) {
71 | if (!animated) {
72 | [self.navigationBar layoutSubviews];
73 | }
74 | }
75 | }
76 |
77 | - (nullable UIViewController *)sx_popViewControllerAnimated:(BOOL)animated{
78 | UIViewController *vc = [self sx_popViewControllerAnimated:animated];
79 | if (![UINavigationConfig shared].sx_disableFixSpace) {
80 | if (!animated) {
81 | [self.navigationBar layoutSubviews];
82 | }
83 | }
84 | return vc;
85 | }
86 |
87 | - (nullable NSArray<__kindof UIViewController *> *)sx_popToViewController:(UIViewController *)viewController animated:(BOOL)animated{
88 | NSArray *vcs = [self sx_popToViewController:viewController animated:animated];
89 | if (![UINavigationConfig shared].sx_disableFixSpace) {
90 | if (!animated) {
91 | [self.navigationBar layoutSubviews];
92 | }
93 | }
94 | return vcs;
95 | }
96 |
97 | - (nullable NSArray<__kindof UIViewController *> *)sx_popToRootViewControllerAnimated:(BOOL)animated{
98 | NSArray *vcs = [self sx_popToRootViewControllerAnimated:animated];
99 | if (![UINavigationConfig shared].sx_disableFixSpace) {
100 | if (!animated) {
101 | [self.navigationBar layoutSubviews];
102 | }
103 | }
104 | return vcs;
105 | }
106 |
107 | - (void)sx_setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0){
108 | [self sx_setViewControllers:viewControllers animated:animated];
109 | if (![UINavigationConfig shared].sx_disableFixSpace) {
110 | if (!animated) {
111 | [self.navigationBar layoutSubviews];
112 | }
113 | }
114 | }
115 |
116 | @end
117 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationItem+SXFixSpace.h:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationItem+SXFixSpace.h
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UINavigationItem (SXFixSpace)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UINavigationBar/UINavigationItem+SXFixSpace.m:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationItem+SXFixSpace.m
3 | // UINavigation-SXFixSpace
4 | //
5 | // Created by charles on 2018/4/20.
6 | // Copyright © 2018年 None. All rights reserved.
7 | //
8 |
9 | #import "UINavigationItem+SXFixSpace.h"
10 | #import "NSObject+SXRuntime.h"
11 | #import "UINavigationConfig.h"
12 |
13 | #ifndef sx_deviceVersion
14 | #define sx_deviceVersion [[[UIDevice currentDevice] systemVersion] floatValue]
15 | #endif
16 |
17 | @implementation UINavigationItem (SXFixSpace)
18 |
19 | +(void)load {
20 | static dispatch_once_t onceToken;
21 | dispatch_once(&onceToken, ^{
22 | [self swizzleInstanceMethodWithOriginSel:@selector(setLeftBarButtonItem:)
23 | swizzledSel:@selector(sx_setLeftBarButtonItem:)];
24 |
25 | [self swizzleInstanceMethodWithOriginSel:@selector(setLeftBarButtonItems:)
26 | swizzledSel:@selector(sx_setLeftBarButtonItems:)];
27 |
28 | [self swizzleInstanceMethodWithOriginSel:@selector(setRightBarButtonItem:)
29 | swizzledSel:@selector(sx_setRightBarButtonItem:)];
30 |
31 | [self swizzleInstanceMethodWithOriginSel:@selector(setRightBarButtonItems:)
32 | swizzledSel:@selector(sx_setRightBarButtonItems:)];
33 | });
34 |
35 | }
36 |
37 | -(void)sx_setLeftBarButtonItem:(UIBarButtonItem *)leftBarButtonItem {
38 | if (sx_deviceVersion >= 11) {
39 | [self sx_setLeftBarButtonItem:leftBarButtonItem];
40 | } else {
41 | if (![UINavigationConfig shared].sx_disableFixSpace && leftBarButtonItem) {//存在按钮且需要调节
42 | [self setLeftBarButtonItems:@[leftBarButtonItem]];
43 | } else {//不存在按钮,或者不需要调节
44 | [self sx_setLeftBarButtonItem:leftBarButtonItem];
45 | }
46 | }
47 | }
48 |
49 | -(void)sx_setLeftBarButtonItems:(NSArray *)leftBarButtonItems {
50 | if (leftBarButtonItems.count) {
51 | NSMutableArray *items = [NSMutableArray arrayWithObject:[self fixedSpaceWithWidth:[UINavigationConfig shared].sx_defaultFixSpace-20]];//可修正iOS11之前的偏移
52 | [items addObjectsFromArray:leftBarButtonItems];
53 | [self sx_setLeftBarButtonItems:items];
54 | } else {
55 | [self sx_setLeftBarButtonItems:leftBarButtonItems];
56 | }
57 | }
58 |
59 | -(void)sx_setRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem{
60 | if (sx_deviceVersion >= 11) {
61 | [self sx_setRightBarButtonItem:rightBarButtonItem];
62 | } else {
63 | if (![UINavigationConfig shared].sx_disableFixSpace && rightBarButtonItem) {//存在按钮且需要调节
64 | [self setRightBarButtonItems:@[rightBarButtonItem]];
65 | } else {//不存在按钮,或者不需要调节
66 | [self sx_setRightBarButtonItem:rightBarButtonItem];
67 | }
68 | }
69 | }
70 |
71 | -(void)sx_setRightBarButtonItems:(NSArray *)rightBarButtonItems{
72 | if (rightBarButtonItems.count) {
73 | NSMutableArray *items = [NSMutableArray arrayWithObject:[self fixedSpaceWithWidth:[UINavigationConfig shared].sx_defaultFixSpace-20]];//可修正iOS11之前的偏移
74 | [items addObjectsFromArray:rightBarButtonItems];
75 | [self sx_setRightBarButtonItems:items];
76 | } else {
77 | [self sx_setRightBarButtonItems:rightBarButtonItems];
78 | }
79 | }
80 |
81 | -(UIBarButtonItem *)fixedSpaceWithWidth:(CGFloat)width {
82 | UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
83 | target:nil
84 | action:nil];
85 | fixedSpace.width = width;
86 | return fixedSpace;
87 | }
88 |
89 | @end
90 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UIViewController+BarButton.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+BarButton.h
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIViewController (BarButton)
12 |
13 | - (void)addLeftBarButtonWithImage:(UIImage *)image action:(SEL)action;
14 |
15 | - (void)addRightBarButtonWithFirstImage:(UIImage *)firstImage action:(SEL)action;
16 | - (void)addRightBarButtonItemWithTitle:(NSString *)itemTitle action:(SEL)action;
17 | - (void)addLeftBarButtonItemWithTitle:(NSString *)itemTitle action:(SEL)action;
18 |
19 | - (void)addRightTwoBarButtonsWithFirstImage:(UIImage *)firstImage firstAction:(SEL)firstAction secondImage:(UIImage *)secondImage secondAction:(SEL)secondAction;
20 | - (void)addRightThreeBarButtonsWithFirstImage:(UIImage *)firstImage firstAction:(SEL)firstAction secondImage:(UIImage *)secondImage secondAction:(SEL)secondAction thirdImage:(UIImage *)thirdImage thirdAction:(SEL)thirdAction;
21 | - (void)addRightFourBarButtonsWithFirstImage:(UIImage *)firstImage firstAction:(SEL)firstAction secondImage:(UIImage *)secondImage secondAction:(SEL)secondAction thirdImage:(UIImage *)thirdImage thirdAction:(SEL)thirdAction fourthImage:(UIImage *)fourthImage fourthAction:(SEL)fourthAction;
22 |
23 | /** 导航标题设置 */
24 | -(void)setNavTitle:(NSString *)title;
25 | -(void)setNavTitle:(NSString *)title withAction:(SEL)action;
26 | -(void)setNavTitle:(NSString *)title withColor:(UIColor *)color;
27 |
28 |
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/UIViewController+BarButton.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+BarButton.m
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import "UIViewController+BarButton.h"
10 |
11 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width
12 | #define kScreenHeight ([UIScreen mainScreen].bounds.size.height)
13 | #define kBlackColor [UIColor blackColor]
14 |
15 | @implementation UIViewController (BarButton)
16 |
17 | - (void)addLeftBarButtonWithImage:(UIImage *)image action:(SEL)action{
18 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
19 | view.backgroundColor = [UIColor clearColor];
20 | UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
21 | firstButton.frame = CGRectMake(0, 0, 44, 44);
22 | [firstButton setImage:image forState:UIControlStateNormal];
23 | [firstButton addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
24 | firstButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
25 | [firstButton setImageEdgeInsets:UIEdgeInsetsMake(0, 5 * kScreenWidth / 375.0, 0, 0)];
26 |
27 | UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:firstButton];
28 | self.navigationItem.leftBarButtonItem = leftBarButtonItem;
29 | }
30 |
31 | - (void)addRightBarButtonWithFirstImage:(UIImage *)firstImage action:(SEL)action
32 | {
33 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
34 | view.backgroundColor = [UIColor clearColor];
35 |
36 | UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
37 | firstButton.frame = CGRectMake(0, 0, 44, 44);
38 | [firstButton setImage:firstImage forState:UIControlStateNormal];
39 | [firstButton addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
40 | firstButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
41 | [firstButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 5 * kScreenWidth / 375.0)];
42 |
43 | UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:firstButton];
44 | self.navigationItem.rightBarButtonItem = rightBarButtonItem;
45 | }
46 |
47 | - (void)addLeftBarButtonItemWithTitle:(NSString *)itemTitle action:(SEL)action
48 | {
49 | UIButton *leftbBarButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 44, 44)];
50 | [leftbBarButton setTitle:itemTitle forState:(UIControlStateNormal)];
51 | [leftbBarButton setTitleColor:kBlackColor forState:(UIControlStateNormal)];
52 | leftbBarButton.titleLabel.font = [UIFont systemFontOfSize:16];
53 | [leftbBarButton addTarget:self action:action forControlEvents:(UIControlEventTouchUpInside)];
54 | leftbBarButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
55 | [leftbBarButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 5 * kScreenWidth/375.0, 0, 0)];
56 |
57 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftbBarButton];
58 | }
59 |
60 | - (void)addRightBarButtonItemWithTitle:(NSString *)itemTitle action:(SEL)action
61 | {
62 |
63 | UIButton *rightbBarButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 88, 44)];
64 | [rightbBarButton setTitle:itemTitle forState:(UIControlStateNormal)];
65 | [rightbBarButton setTitleColor:kBlackColor forState:(UIControlStateNormal)];
66 | rightbBarButton.titleLabel.font = [UIFont systemFontOfSize:14];
67 | [rightbBarButton addTarget:self action:action forControlEvents:(UIControlEventTouchUpInside)];
68 | rightbBarButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
69 | [rightbBarButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 5 * kScreenWidth/375.0)];
70 |
71 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightbBarButton];
72 | }
73 |
74 | - (void)addRightTwoBarButtonsWithFirstImage:(UIImage *)firstImage firstAction:(SEL)firstAction secondImage:(UIImage *)secondImage secondAction:(SEL)secondAction
75 | {
76 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 44)];
77 | view.backgroundColor = [UIColor clearColor];
78 |
79 | UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
80 | firstButton.frame = CGRectMake(40, 0, 40, 44);
81 | [firstButton setImage:firstImage forState:UIControlStateNormal];
82 | [firstButton addTarget:self action:firstAction forControlEvents:UIControlEventTouchUpInside];
83 | firstButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
84 | [firstButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, - 8 * kScreenWidth/375.0)];
85 | [view addSubview:firstButton];
86 |
87 | UIButton *secondButton = [UIButton buttonWithType:UIButtonTypeCustom];
88 | secondButton.frame = CGRectMake(0, 0, 40, 44);
89 | [secondButton setImage:secondImage forState:UIControlStateNormal];
90 | [secondButton addTarget:self action:secondAction forControlEvents:UIControlEventTouchUpInside];
91 | secondButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
92 | [secondButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, - 15 * kScreenWidth/375.0)];
93 | [view addSubview:secondButton];
94 |
95 | UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:view];
96 | self.navigationItem.rightBarButtonItem = rightBarButtonItem;
97 | }
98 |
99 | - (void)addRightThreeBarButtonsWithFirstImage:(UIImage *)firstImage firstAction:(SEL)firstAction secondImage:(UIImage *)secondImage secondAction:(SEL)secondAction thirdImage:(UIImage *)thirdImage thirdAction:(SEL)thirdAction
100 | {
101 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 120, 44)];
102 | view.backgroundColor = [UIColor clearColor];
103 |
104 | UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
105 | firstButton.frame = CGRectMake(80, 0, 40, 44);
106 | [firstButton setImage:firstImage forState:UIControlStateNormal];
107 | [firstButton addTarget:self action:firstAction forControlEvents:UIControlEventTouchUpInside];
108 | firstButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
109 | [firstButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, - 8 * kScreenWidth/375.0)];
110 | [view addSubview:firstButton];
111 |
112 | UIButton *secondButton = [UIButton buttonWithType:UIButtonTypeCustom];
113 | secondButton.frame = CGRectMake(44, 0, 40, 44);
114 | [secondButton setImage:secondImage forState:UIControlStateNormal];
115 | [secondButton addTarget:self action:secondAction forControlEvents:UIControlEventTouchUpInside];
116 | secondButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
117 | [secondButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, - 5 * kScreenWidth/375.0)];
118 | [view addSubview:secondButton];
119 |
120 | UIButton *thirdButton = [UIButton buttonWithType:UIButtonTypeCustom];
121 | thirdButton.frame = CGRectMake(0, 0, 40, 44);
122 | [thirdButton setImage:thirdImage forState:UIControlStateNormal];
123 | [thirdButton addTarget:self action:thirdAction forControlEvents:UIControlEventTouchUpInside];
124 | [thirdButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, - 5 * kScreenWidth/375.0)];
125 | [view addSubview:thirdButton];
126 |
127 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:view];
128 | }
129 |
130 | - (void)addRightFourBarButtonsWithFirstImage:(UIImage *)firstImage firstAction:(SEL)firstAction secondImage:(UIImage *)secondImage secondAction:(SEL)secondAction thirdImage:(UIImage *)thirdImage thirdAction:(SEL)thirdAction fourthImage:(UIImage *)fourthImage fourthAction:(SEL)fourthAction{
131 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 145, 44)];
132 | view.backgroundColor = [UIColor clearColor];
133 |
134 | UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
135 | firstButton.frame = CGRectMake(110, 6, 30, 30);
136 | [firstButton setImage:firstImage forState:UIControlStateNormal];
137 | [firstButton addTarget:self action:firstAction forControlEvents:UIControlEventTouchUpInside];
138 | firstButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
139 | [firstButton setImageEdgeInsets:UIEdgeInsetsMake(0, 8 * kScreenWidth/375.0, 0, 0)];
140 | [view addSubview:firstButton];
141 |
142 | UIButton *secondButton = [UIButton buttonWithType:UIButtonTypeCustom];
143 | secondButton.frame = CGRectMake(80, 6, 30, 30);
144 | [secondButton setImage:secondImage forState:UIControlStateNormal];
145 | [secondButton addTarget:self action:secondAction forControlEvents:UIControlEventTouchUpInside];
146 | secondButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
147 | [secondButton setImageEdgeInsets:UIEdgeInsetsMake(0, 8 * kScreenWidth/375.0, 0, 0)];
148 | [view addSubview:secondButton];
149 |
150 | UIButton *thirdButton = [UIButton buttonWithType:UIButtonTypeCustom];
151 | thirdButton.frame = CGRectMake(50, 6, 30, 30);
152 | [thirdButton setImage:thirdImage forState:UIControlStateNormal];
153 | thirdButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
154 | [thirdButton setImageEdgeInsets:UIEdgeInsetsMake(0, 8 * kScreenWidth/375.0, 0, 0)];
155 | [thirdButton addTarget:self action:thirdAction forControlEvents:UIControlEventTouchUpInside];
156 | [view addSubview:thirdButton];
157 |
158 | UIButton *fourthButton = [UIButton buttonWithType:UIButtonTypeCustom];
159 | fourthButton.frame = CGRectMake(15, 6, 30, 30);
160 | [fourthButton setImage:fourthImage forState:UIControlStateNormal];
161 | [fourthButton addTarget:self action:fourthAction forControlEvents:UIControlEventTouchUpInside];
162 | fourthButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
163 | [fourthButton setImageEdgeInsets:UIEdgeInsetsMake(0, 8 * kScreenWidth/375.0, 0, 0)];
164 | [view addSubview:fourthButton];
165 |
166 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:view];
167 | }
168 |
169 |
170 | -(void)setNavTitle:(NSString *)title
171 | {
172 |
173 | UILabel *navTitleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
174 | [navTitleView setText:title];
175 | [navTitleView setFont:[UIFont systemFontOfSize:17]];
176 | // [navTitleView setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17.f]];
177 | [navTitleView setTextColor:[UIColor whiteColor]];
178 | [navTitleView setTextAlignment:NSTextAlignmentCenter];
179 | [self.navigationItem setTitleView:navTitleView];
180 | }
181 | -(void)setNavTitle:(NSString *)title withColor:(UIColor *)color{
182 | UILabel *navTitleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
183 | [navTitleView setText:title];
184 | [navTitleView setFont:[UIFont systemFontOfSize:18]];
185 | [navTitleView setTextColor:color];
186 | [navTitleView setTextAlignment:NSTextAlignmentCenter];
187 | [self.navigationItem setTitleView:navTitleView];
188 | }
189 |
190 |
191 | -(void)setNavTitle:(NSString *)title withAction:(SEL)action
192 | {
193 | UILabel *navTitleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
194 | [navTitleView setText:title];
195 | [navTitleView setTextColor:[UIColor whiteColor]];
196 | [navTitleView setFont:[UIFont systemFontOfSize:17]];
197 | [navTitleView setTextAlignment:NSTextAlignmentCenter];
198 | if (action && [self respondsToSelector:action]) {
199 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:action];
200 | [navTitleView addGestureRecognizer:tap];
201 | [navTitleView setUserInteractionEnabled:YES];
202 | [self.navigationItem setTitleView:navTitleView];
203 | }
204 | }
205 |
206 |
207 |
208 |
209 |
210 | @end
211 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "Demo1ViewController.h"
11 | #import "UIViewController+BarButton.h"
12 |
13 | @interface ViewController ()
14 |
15 | @end
16 |
17 | @implementation ViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view, typically from a nib.
22 |
23 | self.view.backgroundColor = [UIColor blueColor];
24 |
25 |
26 | self.navigationController.navigationBar.translucent = NO;
27 | self.tabBarController.tabBar.translucent = NO;
28 |
29 |
30 |
31 |
32 | UIBarButtonItem *btn1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"mine-sun-icon"] style:UIBarButtonItemStyleDone target:self action:@selector(btn1Action)];
33 |
34 | UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_coin_icon_click"] style:UIBarButtonItemStyleDone target:self action:@selector(btn2Action)];
35 |
36 | self.navigationItem.rightBarButtonItems = @[btn1, btn2];
37 |
38 |
39 | // [self setNavTitle:@"首页"];
40 |
41 | [self setNavTitle:@"第一页" withColor:[UIColor blackColor]];
42 | }
43 |
44 |
45 | - (void)btn1Action{
46 |
47 |
48 | }
49 |
50 |
51 | - (void)btn2Action{
52 |
53 |
54 |
55 | }
56 |
57 |
58 |
59 |
60 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
61 |
62 | Demo1ViewController *demo = [[Demo1ViewController alloc] init];
63 | [self.navigationController pushViewController:demo animated:YES];
64 | }
65 |
66 |
67 | - (void)didReceiveMemoryWarning {
68 | [super didReceiveMemoryWarning];
69 | // Dispose of any resources that can be recreated.
70 | }
71 |
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/XTNavigationItemDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // XTNavigationItemDemo
4 | //
5 | // Created by chenzhen on 2017/11/6.
6 | // Copyright © 2017年 sjxt.me. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------