├── Assets.xcassets
├── AppIcon.appiconset
│ └── Contents.json
├── Contents.json
├── clear.imageset
│ ├── Contents.json
│ └── cancle.png
├── guaishou.imageset
│ ├── Contents.json
│ └── 怪兽福利.png
├── msg.imageset
│ ├── Contents.json
│ └── message.png
├── scan.imageset
│ ├── Contents.json
│ └── scan.png
└── search.imageset
│ ├── Contents.json
│ └── search.png
├── Base.lproj
└── LaunchScreen.storyboard
├── Info.plist
├── OHSearchBarInNaviBar.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── xing.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── xing.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ └── xcschememanagement.plist
├── OHSearchBarInNaviBar
├── AppDelegate.h
├── AppDelegate.m
├── OHHomeViewController.h
├── OHHomeViewController.m
├── OHSearchBar.h
├── OHSearchBar.m
├── OHSearchController.h
├── OHSearchController.m
├── OHSearchViewController.h
├── OHSearchViewController.m
└── PrefixHeader.pch
├── README.md
└── main.m
/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 | }
--------------------------------------------------------------------------------
/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Assets.xcassets/clear.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "cancle.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Assets.xcassets/clear.imageset/cancle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sinter0/OHSearchBarInNaviBar/5133a818c49ca9f52ba9046e4f84699dd2b0ed76/Assets.xcassets/clear.imageset/cancle.png
--------------------------------------------------------------------------------
/Assets.xcassets/guaishou.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "怪兽福利.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Assets.xcassets/guaishou.imageset/怪兽福利.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sinter0/OHSearchBarInNaviBar/5133a818c49ca9f52ba9046e4f84699dd2b0ed76/Assets.xcassets/guaishou.imageset/怪兽福利.png
--------------------------------------------------------------------------------
/Assets.xcassets/msg.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "message.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Assets.xcassets/msg.imageset/message.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sinter0/OHSearchBarInNaviBar/5133a818c49ca9f52ba9046e4f84699dd2b0ed76/Assets.xcassets/msg.imageset/message.png
--------------------------------------------------------------------------------
/Assets.xcassets/scan.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "scan.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Assets.xcassets/scan.imageset/scan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sinter0/OHSearchBarInNaviBar/5133a818c49ca9f52ba9046e4f84699dd2b0ed76/Assets.xcassets/scan.imageset/scan.png
--------------------------------------------------------------------------------
/Assets.xcassets/search.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "search.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Assets.xcassets/search.imageset/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sinter0/OHSearchBarInNaviBar/5133a818c49ca9f52ba9046e4f84699dd2b0ed76/Assets.xcassets/search.imageset/search.png
--------------------------------------------------------------------------------
/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 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/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 | UIRequiredDeviceCapabilities
26 |
27 | armv7
28 |
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 |
33 | UISupportedInterfaceOrientations~ipad
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationPortraitUpsideDown
37 | UIInterfaceOrientationLandscapeLeft
38 | UIInterfaceOrientationLandscapeRight
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 48;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 2146BC811FD517DE0028113E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2146BC801FD517DE0028113E /* AppDelegate.m */; };
11 | 2146BC891FD517DE0028113E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2146BC881FD517DE0028113E /* Assets.xcassets */; };
12 | 2146BC8C1FD517DE0028113E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2146BC8A1FD517DE0028113E /* LaunchScreen.storyboard */; };
13 | 2146BC8F1FD517DE0028113E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2146BC8E1FD517DE0028113E /* main.m */; };
14 | 2146BC9D1FD527810028113E /* OHSearchBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 2146BC9C1FD527810028113E /* OHSearchBar.m */; };
15 | 2146BCA21FD5280A0028113E /* OHSearchController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2146BCA11FD5280A0028113E /* OHSearchController.m */; };
16 | 215844661FD548FA00A1137C /* OHHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 215844651FD548FA00A1137C /* OHHomeViewController.m */; };
17 | 215844691FD5490B00A1137C /* OHSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 215844681FD5490B00A1137C /* OHSearchViewController.m */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXFileReference section */
21 | 2146BC7C1FD517DE0028113E /* OHSearchBarInNaviBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OHSearchBarInNaviBar.app; sourceTree = BUILT_PRODUCTS_DIR; };
22 | 2146BC7F1FD517DE0028113E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
23 | 2146BC801FD517DE0028113E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
24 | 2146BC881FD517DE0028113E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
25 | 2146BC8B1FD517DE0028113E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
26 | 2146BC8D1FD517DE0028113E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
27 | 2146BC8E1FD517DE0028113E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
28 | 2146BC9B1FD527810028113E /* OHSearchBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OHSearchBar.h; sourceTree = ""; };
29 | 2146BC9C1FD527810028113E /* OHSearchBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OHSearchBar.m; sourceTree = ""; };
30 | 2146BCA01FD5280A0028113E /* OHSearchController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OHSearchController.h; sourceTree = ""; };
31 | 2146BCA11FD5280A0028113E /* OHSearchController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OHSearchController.m; sourceTree = ""; };
32 | 215844631FD5486000A1137C /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = ""; };
33 | 215844641FD548FA00A1137C /* OHHomeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OHHomeViewController.h; sourceTree = ""; };
34 | 215844651FD548FA00A1137C /* OHHomeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OHHomeViewController.m; sourceTree = ""; };
35 | 215844671FD5490B00A1137C /* OHSearchViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OHSearchViewController.h; sourceTree = ""; };
36 | 215844681FD5490B00A1137C /* OHSearchViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OHSearchViewController.m; sourceTree = ""; };
37 | /* End PBXFileReference section */
38 |
39 | /* Begin PBXFrameworksBuildPhase section */
40 | 2146BC791FD517DE0028113E /* Frameworks */ = {
41 | isa = PBXFrameworksBuildPhase;
42 | buildActionMask = 2147483647;
43 | files = (
44 | );
45 | runOnlyForDeploymentPostprocessing = 0;
46 | };
47 | /* End PBXFrameworksBuildPhase section */
48 |
49 | /* Begin PBXGroup section */
50 | 2146BC731FD517DE0028113E = {
51 | isa = PBXGroup;
52 | children = (
53 | 2146BC7E1FD517DE0028113E /* OHSearchBarInNaviBar */,
54 | 2146BCED1FD52C1D0028113E /* others */,
55 | 2146BC7D1FD517DE0028113E /* Products */,
56 | );
57 | sourceTree = "";
58 | };
59 | 2146BC7D1FD517DE0028113E /* Products */ = {
60 | isa = PBXGroup;
61 | children = (
62 | 2146BC7C1FD517DE0028113E /* OHSearchBarInNaviBar.app */,
63 | );
64 | name = Products;
65 | sourceTree = "";
66 | };
67 | 2146BC7E1FD517DE0028113E /* OHSearchBarInNaviBar */ = {
68 | isa = PBXGroup;
69 | children = (
70 | 215844631FD5486000A1137C /* PrefixHeader.pch */,
71 | 2146BC7F1FD517DE0028113E /* AppDelegate.h */,
72 | 2146BC801FD517DE0028113E /* AppDelegate.m */,
73 | 2146BC9B1FD527810028113E /* OHSearchBar.h */,
74 | 2146BC9C1FD527810028113E /* OHSearchBar.m */,
75 | 2146BCA01FD5280A0028113E /* OHSearchController.h */,
76 | 2146BCA11FD5280A0028113E /* OHSearchController.m */,
77 | 215844641FD548FA00A1137C /* OHHomeViewController.h */,
78 | 215844651FD548FA00A1137C /* OHHomeViewController.m */,
79 | 215844671FD5490B00A1137C /* OHSearchViewController.h */,
80 | 215844681FD5490B00A1137C /* OHSearchViewController.m */,
81 | );
82 | path = OHSearchBarInNaviBar;
83 | sourceTree = "";
84 | };
85 | 2146BCED1FD52C1D0028113E /* others */ = {
86 | isa = PBXGroup;
87 | children = (
88 | 2146BC881FD517DE0028113E /* Assets.xcassets */,
89 | 2146BC8A1FD517DE0028113E /* LaunchScreen.storyboard */,
90 | 2146BC8D1FD517DE0028113E /* Info.plist */,
91 | 2146BC8E1FD517DE0028113E /* main.m */,
92 | );
93 | name = others;
94 | sourceTree = "";
95 | };
96 | /* End PBXGroup section */
97 |
98 | /* Begin PBXNativeTarget section */
99 | 2146BC7B1FD517DE0028113E /* OHSearchBarInNaviBar */ = {
100 | isa = PBXNativeTarget;
101 | buildConfigurationList = 2146BC921FD517DE0028113E /* Build configuration list for PBXNativeTarget "OHSearchBarInNaviBar" */;
102 | buildPhases = (
103 | 2146BC781FD517DE0028113E /* Sources */,
104 | 2146BC791FD517DE0028113E /* Frameworks */,
105 | 2146BC7A1FD517DE0028113E /* Resources */,
106 | );
107 | buildRules = (
108 | );
109 | dependencies = (
110 | );
111 | name = OHSearchBarInNaviBar;
112 | productName = OHSearchController;
113 | productReference = 2146BC7C1FD517DE0028113E /* OHSearchBarInNaviBar.app */;
114 | productType = "com.apple.product-type.application";
115 | };
116 | /* End PBXNativeTarget section */
117 |
118 | /* Begin PBXProject section */
119 | 2146BC741FD517DE0028113E /* Project object */ = {
120 | isa = PBXProject;
121 | attributes = {
122 | LastUpgradeCheck = 0910;
123 | ORGANIZATIONNAME = HasjOH;
124 | TargetAttributes = {
125 | 2146BC7B1FD517DE0028113E = {
126 | CreatedOnToolsVersion = 9.1;
127 | ProvisioningStyle = Automatic;
128 | };
129 | };
130 | };
131 | buildConfigurationList = 2146BC771FD517DE0028113E /* Build configuration list for PBXProject "OHSearchBarInNaviBar" */;
132 | compatibilityVersion = "Xcode 8.0";
133 | developmentRegion = en;
134 | hasScannedForEncodings = 0;
135 | knownRegions = (
136 | en,
137 | Base,
138 | );
139 | mainGroup = 2146BC731FD517DE0028113E;
140 | productRefGroup = 2146BC7D1FD517DE0028113E /* Products */;
141 | projectDirPath = "";
142 | projectRoot = "";
143 | targets = (
144 | 2146BC7B1FD517DE0028113E /* OHSearchBarInNaviBar */,
145 | );
146 | };
147 | /* End PBXProject section */
148 |
149 | /* Begin PBXResourcesBuildPhase section */
150 | 2146BC7A1FD517DE0028113E /* Resources */ = {
151 | isa = PBXResourcesBuildPhase;
152 | buildActionMask = 2147483647;
153 | files = (
154 | 2146BC8C1FD517DE0028113E /* LaunchScreen.storyboard in Resources */,
155 | 2146BC891FD517DE0028113E /* Assets.xcassets in Resources */,
156 | );
157 | runOnlyForDeploymentPostprocessing = 0;
158 | };
159 | /* End PBXResourcesBuildPhase section */
160 |
161 | /* Begin PBXSourcesBuildPhase section */
162 | 2146BC781FD517DE0028113E /* Sources */ = {
163 | isa = PBXSourcesBuildPhase;
164 | buildActionMask = 2147483647;
165 | files = (
166 | 2146BC8F1FD517DE0028113E /* main.m in Sources */,
167 | 2146BC811FD517DE0028113E /* AppDelegate.m in Sources */,
168 | 2146BCA21FD5280A0028113E /* OHSearchController.m in Sources */,
169 | 215844661FD548FA00A1137C /* OHHomeViewController.m in Sources */,
170 | 215844691FD5490B00A1137C /* OHSearchViewController.m in Sources */,
171 | 2146BC9D1FD527810028113E /* OHSearchBar.m in Sources */,
172 | );
173 | runOnlyForDeploymentPostprocessing = 0;
174 | };
175 | /* End PBXSourcesBuildPhase section */
176 |
177 | /* Begin PBXVariantGroup section */
178 | 2146BC8A1FD517DE0028113E /* LaunchScreen.storyboard */ = {
179 | isa = PBXVariantGroup;
180 | children = (
181 | 2146BC8B1FD517DE0028113E /* Base */,
182 | );
183 | name = LaunchScreen.storyboard;
184 | sourceTree = "";
185 | };
186 | /* End PBXVariantGroup section */
187 |
188 | /* Begin XCBuildConfiguration section */
189 | 2146BC901FD517DE0028113E /* Debug */ = {
190 | isa = XCBuildConfiguration;
191 | buildSettings = {
192 | ALWAYS_SEARCH_USER_PATHS = NO;
193 | CLANG_ANALYZER_NONNULL = YES;
194 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
195 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
196 | CLANG_CXX_LIBRARY = "libc++";
197 | CLANG_ENABLE_MODULES = YES;
198 | CLANG_ENABLE_OBJC_ARC = YES;
199 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
200 | CLANG_WARN_BOOL_CONVERSION = YES;
201 | CLANG_WARN_COMMA = YES;
202 | CLANG_WARN_CONSTANT_CONVERSION = YES;
203 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
204 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
205 | CLANG_WARN_EMPTY_BODY = YES;
206 | CLANG_WARN_ENUM_CONVERSION = YES;
207 | CLANG_WARN_INFINITE_RECURSION = YES;
208 | CLANG_WARN_INT_CONVERSION = YES;
209 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
210 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
211 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
212 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
213 | CLANG_WARN_STRICT_PROTOTYPES = YES;
214 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
215 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
216 | CLANG_WARN_UNREACHABLE_CODE = YES;
217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
218 | CODE_SIGN_IDENTITY = "iPhone Developer";
219 | COPY_PHASE_STRIP = NO;
220 | DEBUG_INFORMATION_FORMAT = dwarf;
221 | ENABLE_STRICT_OBJC_MSGSEND = YES;
222 | ENABLE_TESTABILITY = YES;
223 | GCC_C_LANGUAGE_STANDARD = gnu11;
224 | GCC_DYNAMIC_NO_PIC = NO;
225 | GCC_INCREASE_PRECOMPILED_HEADER_SHARING = NO;
226 | GCC_NO_COMMON_BLOCKS = YES;
227 | GCC_OPTIMIZATION_LEVEL = 0;
228 | GCC_PREPROCESSOR_DEFINITIONS = (
229 | "DEBUG=1",
230 | "$(inherited)",
231 | );
232 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
233 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
234 | GCC_WARN_UNDECLARED_SELECTOR = YES;
235 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
236 | GCC_WARN_UNUSED_FUNCTION = YES;
237 | GCC_WARN_UNUSED_VARIABLE = YES;
238 | IPHONEOS_DEPLOYMENT_TARGET = 11.1;
239 | MTL_ENABLE_DEBUG_INFO = YES;
240 | ONLY_ACTIVE_ARCH = YES;
241 | SDKROOT = iphoneos;
242 | };
243 | name = Debug;
244 | };
245 | 2146BC911FD517DE0028113E /* Release */ = {
246 | isa = XCBuildConfiguration;
247 | buildSettings = {
248 | ALWAYS_SEARCH_USER_PATHS = NO;
249 | CLANG_ANALYZER_NONNULL = YES;
250 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
252 | CLANG_CXX_LIBRARY = "libc++";
253 | CLANG_ENABLE_MODULES = YES;
254 | CLANG_ENABLE_OBJC_ARC = YES;
255 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
256 | CLANG_WARN_BOOL_CONVERSION = YES;
257 | CLANG_WARN_COMMA = YES;
258 | CLANG_WARN_CONSTANT_CONVERSION = YES;
259 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
260 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
261 | CLANG_WARN_EMPTY_BODY = YES;
262 | CLANG_WARN_ENUM_CONVERSION = YES;
263 | CLANG_WARN_INFINITE_RECURSION = YES;
264 | CLANG_WARN_INT_CONVERSION = YES;
265 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
266 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
267 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
268 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
269 | CLANG_WARN_STRICT_PROTOTYPES = YES;
270 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
271 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
272 | CLANG_WARN_UNREACHABLE_CODE = YES;
273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
274 | CODE_SIGN_IDENTITY = "iPhone Developer";
275 | COPY_PHASE_STRIP = NO;
276 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
277 | ENABLE_NS_ASSERTIONS = NO;
278 | ENABLE_STRICT_OBJC_MSGSEND = YES;
279 | GCC_C_LANGUAGE_STANDARD = gnu11;
280 | GCC_INCREASE_PRECOMPILED_HEADER_SHARING = NO;
281 | GCC_NO_COMMON_BLOCKS = YES;
282 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
283 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
284 | GCC_WARN_UNDECLARED_SELECTOR = YES;
285 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
286 | GCC_WARN_UNUSED_FUNCTION = YES;
287 | GCC_WARN_UNUSED_VARIABLE = YES;
288 | IPHONEOS_DEPLOYMENT_TARGET = 11.1;
289 | MTL_ENABLE_DEBUG_INFO = NO;
290 | SDKROOT = iphoneos;
291 | VALIDATE_PRODUCT = YES;
292 | };
293 | name = Release;
294 | };
295 | 2146BC931FD517DE0028113E /* Debug */ = {
296 | isa = XCBuildConfiguration;
297 | buildSettings = {
298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
299 | CODE_SIGN_STYLE = Automatic;
300 | DEVELOPMENT_TEAM = D348HE7S39;
301 | GCC_PREFIX_HEADER = "$(SRCROOT)/OHSearchBarInNaviBar/PrefixHeader.pch";
302 | INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
303 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
304 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
305 | NEW_SETTING = "";
306 | PRODUCT_BUNDLE_IDENTIFIER = com.hajsoh.OHSearchBarInNaviBar;
307 | PRODUCT_NAME = "$(TARGET_NAME)";
308 | TARGETED_DEVICE_FAMILY = "1,2";
309 | };
310 | name = Debug;
311 | };
312 | 2146BC941FD517DE0028113E /* Release */ = {
313 | isa = XCBuildConfiguration;
314 | buildSettings = {
315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
316 | CODE_SIGN_STYLE = Automatic;
317 | DEVELOPMENT_TEAM = D348HE7S39;
318 | GCC_PREFIX_HEADER = "$(SRCROOT)/OHSearchBarInNaviBar/PrefixHeader.pch";
319 | INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
320 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
321 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
322 | NEW_SETTING = "";
323 | PRODUCT_BUNDLE_IDENTIFIER = com.hajsoh.OHSearchBarInNaviBar;
324 | PRODUCT_NAME = "$(TARGET_NAME)";
325 | TARGETED_DEVICE_FAMILY = "1,2";
326 | };
327 | name = Release;
328 | };
329 | /* End XCBuildConfiguration section */
330 |
331 | /* Begin XCConfigurationList section */
332 | 2146BC771FD517DE0028113E /* Build configuration list for PBXProject "OHSearchBarInNaviBar" */ = {
333 | isa = XCConfigurationList;
334 | buildConfigurations = (
335 | 2146BC901FD517DE0028113E /* Debug */,
336 | 2146BC911FD517DE0028113E /* Release */,
337 | );
338 | defaultConfigurationIsVisible = 0;
339 | defaultConfigurationName = Release;
340 | };
341 | 2146BC921FD517DE0028113E /* Build configuration list for PBXNativeTarget "OHSearchBarInNaviBar" */ = {
342 | isa = XCConfigurationList;
343 | buildConfigurations = (
344 | 2146BC931FD517DE0028113E /* Debug */,
345 | 2146BC941FD517DE0028113E /* Release */,
346 | );
347 | defaultConfigurationIsVisible = 0;
348 | defaultConfigurationName = Release;
349 | };
350 | /* End XCConfigurationList section */
351 | };
352 | rootObject = 2146BC741FD517DE0028113E /* Project object */;
353 | }
354 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar.xcodeproj/project.xcworkspace/xcuserdata/xing.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sinter0/OHSearchBarInNaviBar/5133a818c49ca9f52ba9046e4f84699dd2b0ed76/OHSearchBarInNaviBar.xcodeproj/project.xcworkspace/xcuserdata/xing.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar.xcodeproj/xcuserdata/xing.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar.xcodeproj/xcuserdata/xing.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | OHSearchBarInNaviBar.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 | OHSearchController.xcscheme
13 |
14 | orderHint
15 | 0
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //2C3235
2 | // AppDelegate.m
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "OHHomeViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | OHHomeViewController *homeViewController = [[OHHomeViewController alloc] init];
20 | UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
21 | navigationController.navigationBar.barTintColor = BASE_BLUE_COLOR;
22 | navigationController.navigationBar.tintColor = [UIColor whiteColor];
23 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
24 | self.window.rootViewController = navigationController;
25 | [self.window makeKeyAndVisible];
26 |
27 | return YES;
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHHomeViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // OHHomeViewController.h
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "OHSearchController.h"
11 |
12 | @interface OHHomeViewController : UIViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHHomeViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // OHHomeViewController.m
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import "OHHomeViewController.h"
10 | #import "OHSearchBar.h"
11 | #import "OHSearchViewController.h"
12 |
13 | @interface OHHomeViewController ()
14 |
15 | @property (nonatomic, strong) OHSearchBar *ohSearchBar;
16 |
17 | @end
18 |
19 | @implementation OHHomeViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 | self.view.backgroundColor = [UIColor whiteColor];
24 | UILabel *label = [[UILabel alloc] init];
25 | label.text = @"首页";
26 | label.font = [UIFont systemFontOfSize:30];
27 | [label sizeToFit];
28 | label.center = CGPointMake(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
29 | [self.view addSubview:label];
30 |
31 | // navigation buttom
32 | UIButton *messageButton = [UIButton buttonWithType:UIButtonTypeSystem];
33 | [messageButton setImage:[UIImage imageNamed:@"msg"] forState:UIControlStateNormal];
34 | messageButton.bounds = CGRectMake(0, 0, 30, 30);
35 | UIBarButtonItem *messageBarButton = [[UIBarButtonItem alloc] initWithCustomView:messageButton];
36 | self.navigationItem.rightBarButtonItem = messageBarButton;
37 |
38 | // search bar
39 | UIImageView *leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"scan"]];
40 | leftView.bounds = CGRectMake(0, 0, 24, 24);
41 | self.ohSearchBar = [[OHSearchBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)
42 | placeholder:@"点击我跳转"
43 | textFieldLeftView:leftView
44 | showCancelButton:NO
45 | tintColor:[UIColor clearColor]];
46 | self.navigationItem.titleView = self.ohSearchBar;
47 | self.ohSearchBar.delegate = self;
48 | }
49 |
50 | - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
51 | OHSearchViewController *ohSearchViewController = [[OHSearchViewController alloc] init];
52 | [self.navigationController pushViewController:ohSearchViewController animated:NO];
53 | return YES;
54 | }
55 |
56 | - (void)viewWillDisappear:(BOOL)animated {
57 | [self.ohSearchBar resignFirstResponder];
58 | }
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHSearchBar.h:
--------------------------------------------------------------------------------
1 | //
2 | // OHSearchBar.h
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface OHSearchBar : UISearchBar
12 |
13 |
14 | /**
15 | 初始化方法
16 |
17 | @param frame frame
18 | @param placeholder placeholder
19 | @param leftView textField的leftView
20 | @param showCancelButton 是否显示取消按钮
21 | @param tintColor 光标颜色
22 | */
23 | - (instancetype)initWithFrame:(CGRect)frame placeholder:(NSString *)placeholder textFieldLeftView:(UIImageView *)leftView showCancelButton:(BOOL)showCancelButton tintColor:(UIColor *)tintColor;
24 |
25 | /// 让searchBar的内容居左显示
26 | - (void)setLeftPlaceholder;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHSearchBar.m:
--------------------------------------------------------------------------------
1 | //
2 | // OHSearchBar.m
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "OHSearchBar.h"
11 |
12 | @interface OHSearchBar ()
13 |
14 | @property (nonatomic, strong) UIImageView *leftView;
15 |
16 | @end
17 |
18 | @implementation OHSearchBar
19 |
20 |
21 | - (instancetype)initWithFrame:(CGRect)frame placeholder:(NSString *)placeholder textFieldLeftView:(UIImageView *)leftView showCancelButton:(BOOL)showCancelButton tintColor:(UIColor *)tintColor {
22 | if (self = [super initWithFrame:frame]) {
23 | self.frame = frame;
24 | self.tintColor = tintColor; //光标颜色
25 | self.barTintColor = [UIColor whiteColor];
26 | self.placeholder = placeholder;
27 | self.showsCancelButton = showCancelButton;
28 | self.leftView = leftView; // 用来代替左边的放大镜
29 | [self setImage:[UIImage imageNamed:@"clear"] forSearchBarIcon:UISearchBarIconClear state:UIControlStateNormal]; // 替换输入过程中右侧的clearIcon
30 |
31 | if ([[UIDevice currentDevice] systemVersion].doubleValue >= 11.0) {
32 | [[self.heightAnchor constraintEqualToConstant:44.0] setActive:YES];
33 | } else {
34 | [self setLeftPlaceholder];
35 | }
36 | }
37 | return self;
38 | }
39 |
40 | - (void)setLeftPlaceholder {
41 | SEL centerSelector = NSSelectorFromString([NSString stringWithFormat:@"%@%@", @"setCenter", @"Placeholder:"]);
42 | if ([self respondsToSelector:centerSelector]) {
43 | BOOL centeredPlaceholder = NO;
44 | NSMethodSignature *signature = [[UISearchBar class] instanceMethodSignatureForSelector:centerSelector];
45 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
46 | [invocation setTarget:self];
47 | [invocation setSelector:centerSelector];
48 | [invocation setArgument:¢eredPlaceholder atIndex:2];
49 | [invocation invoke];
50 | }
51 | }
52 |
53 | - (void)layoutSubviews{
54 | [super layoutSubviews];
55 |
56 | // search field
57 | UITextField *searchField = [self valueForKey:@"searchField"];
58 | searchField.backgroundColor = DARK_BLUE_COLOR;
59 | searchField.textColor = [UIColor whiteColor];
60 | searchField.font = [UIFont systemFontOfSize:16];
61 | searchField.leftView = self.leftView;
62 |
63 | if (@available(iOS 11.0, *)) {
64 | // 查看视图层级,在iOS 11之前searchbar的x是12
65 | searchField.frame = CGRectMake(12, 8, SCREEN_WIDTH*0.8, 28);
66 |
67 | } else {
68 | searchField.frame = CGRectMake(0, 8, SCREEN_WIDTH*0.8, 28);
69 | }
70 |
71 | searchField.borderStyle = UITextBorderStyleNone;
72 | searchField.layer.cornerRadius = 5;
73 |
74 | searchField.layer.masksToBounds = YES;
75 | [searchField setValue:[UIColor whiteColor] forKeyPath:@"placeholderLabel.textColor"];
76 | [self setValue:searchField forKey:@"searchField"];
77 |
78 | self.searchTextPositionAdjustment = (UIOffset){10, 0}; // 光标偏移量
79 | }
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHSearchController.h:
--------------------------------------------------------------------------------
1 | //
2 | // OHSearchController.h
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "OHSearchBar.h"
11 |
12 | @interface OHSearchController : UISearchController
13 |
14 | @property (nonatomic, strong) OHSearchBar *ohSearchBar;
15 |
16 | - (instancetype)initWithSearchResultsController:(UIViewController *)searchResultsController searchBarFrame:(CGRect)frame placeholder:(NSString *)placeholder textFieldLeftView:(UIImageView *)leftView showCancelButton:(BOOL)showCancelButton barTintColor:(UIColor *)barTintColor;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHSearchController.m:
--------------------------------------------------------------------------------
1 | //
2 | // OHSearchController.m
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import "OHSearchController.h"
10 |
11 | @interface OHSearchController ()
12 |
13 | @end
14 |
15 | @implementation OHSearchController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | self.dimsBackgroundDuringPresentation = NO;
20 | }
21 |
22 | - (instancetype)initWithSearchResultsController:(UIViewController *)searchResultsController searchBarFrame:(CGRect)searchBarFrame placeholder:(NSString *)placeholder textFieldLeftView:(UIImageView *)leftView showCancelButton:(BOOL)showCancelButton barTintColor:(UIColor *)barTintColor{
23 | if (self = [super initWithSearchResultsController:searchResultsController]) {
24 | self.ohSearchBar = [[OHSearchBar alloc] initWithFrame:searchBarFrame
25 | placeholder:placeholder
26 | textFieldLeftView:leftView
27 | showCancelButton:YES
28 | tintColor:barTintColor];
29 |
30 | UIButton *button = [self.ohSearchBar valueForKey:@"cancelButton"];
31 | button.tintColor = [UIColor whiteColor];
32 | [button setTitle:@"取消" forState:UIControlStateNormal];
33 | [self.ohSearchBar setValue:button forKey:@"cancelButton"];
34 | }
35 | return self;
36 | }
37 |
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHSearchViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // OHSearchViewController.h
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface OHSearchViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/OHSearchViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // OHSearchViewController.m
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #import "OHSearchViewController.h"
10 | #import "OHSearchController.h"
11 |
12 | @interface OHSearchViewController ()
13 |
14 | @property (nonatomic, strong) OHSearchController *ohSearchController;
15 |
16 | @end
17 |
18 | @implementation OHSearchViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | self.view.backgroundColor = [UIColor grayColor];
23 | UILabel *label = [[UILabel alloc] init];
24 | label.text = @"搜索页";
25 | label.font = [UIFont systemFontOfSize:30];
26 | [label sizeToFit];
27 | label.center = CGPointMake(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
28 | [self.view addSubview:label];
29 |
30 | UIImageView *leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search"]];
31 | leftView.bounds = CGRectMake(0, 0, 24, 24);
32 | self.ohSearchController = [[OHSearchController alloc] initWithSearchResultsController:self
33 | searchBarFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)
34 | placeholder:@"请输入搜索内容进行搜索"
35 | textFieldLeftView:leftView
36 | showCancelButton:YES
37 | barTintColor:BASE_BLUE_COLOR];
38 |
39 | [self.ohSearchController.ohSearchBar becomeFirstResponder];
40 | self.ohSearchController.ohSearchBar.delegate = self;
41 | [self.ohSearchController.ohSearchBar setLeftPlaceholder];
42 | self.navigationItem.titleView = self.ohSearchController.ohSearchBar;
43 | self.navigationItem.hidesBackButton = YES;
44 | }
45 |
46 | - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
47 | [self.navigationController popViewControllerAnimated:NO];
48 | }
49 |
50 | - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
51 | [self.ohSearchController.ohSearchBar resignFirstResponder];
52 | // 让取消按钮一直处于激活状态
53 | UIButton *cancelBtn = [searchBar valueForKey:@"cancelButton"];
54 | cancelBtn.enabled = YES;
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/OHSearchBarInNaviBar/PrefixHeader.pch:
--------------------------------------------------------------------------------
1 | //
2 | // PrefixHeader.pch
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. All rights reserved.
7 | //
8 |
9 | #ifndef PrefixHeader_pch
10 | #define PrefixHeader_pch
11 |
12 | #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
13 | #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
14 | #define RGBA(r,g,b,a) [UIColor colorWithRed:r green:g blue:b alpha:a]
15 | #define BASE_BLUE_COLOR RGBA(0.35f, 0.68f, 1.0f, 1.0f)
16 | #define DARK_BLUE_COLOR RGBA(0.30, 0.64, 0.91, 1.0f)
17 |
18 | #endif /* PrefixHeader_pch */
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OHSearchBarInNaviBar
2 | Customed searchBar embed in searchBar.
3 | update to iOS 11.
4 | run in Xcode 9.2
5 |
6 | 定制searchBar导航栏,解决了一些在iOS 11下样式不统一的问题,博客见https://juejin.im/post/5a367c9f6fb9a045186ad15b
7 |
--------------------------------------------------------------------------------
/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // OHSearchController
4 | //
5 | // Created by Xing on 2017/12/4.
6 | // Copyright © 2017年 HasjOH. 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 |
--------------------------------------------------------------------------------