Skip to content

Commit 8dbb5af

Browse files
committed
搜索框优化~
1 parent 8edd522 commit 8dbb5af

6 files changed

Lines changed: 30 additions & 6 deletions

File tree

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@
934934
D0C447AF1C02A42C00DC1C4B /* filterBtn_selected_Nav@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0C447AD1C02A42C00DC1C4B /* filterBtn_selected_Nav@2x.png */; };
935935
D0C447B01C02A42C00DC1C4B /* filtertBtn_normal_Nav@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0C447AE1C02A42C00DC1C4B /* filtertBtn_normal_Nav@2x.png */; };
936936
D0C447B21C02A44200DC1C4B /* addBtn_Nav@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0C447B11C02A44200DC1C4B /* addBtn_Nav@2x.png */; };
937+
D0C447B41C02B1DE00DC1C4B /* btn_fliter_down@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0C447B31C02B1DE00DC1C4B /* btn_fliter_down@2x.png */; };
938+
D0C447B61C02B7C000DC1C4B /* icon_search_searchbar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0C447B51C02B7C000DC1C4B /* icon_search_searchbar@2x.png */; };
937939
E7A046A01A47279E00528C12 /* Helper.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A0469F1A47279E00528C12 /* Helper.m */; };
938940
/* End PBXBuildFile section */
939941

@@ -2363,6 +2365,8 @@
23632365
D0C447AD1C02A42C00DC1C4B /* filterBtn_selected_Nav@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "filterBtn_selected_Nav@2x.png"; sourceTree = "<group>"; };
23642366
D0C447AE1C02A42C00DC1C4B /* filtertBtn_normal_Nav@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "filtertBtn_normal_Nav@2x.png"; sourceTree = "<group>"; };
23652367
D0C447B11C02A44200DC1C4B /* addBtn_Nav@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "addBtn_Nav@2x.png"; sourceTree = "<group>"; };
2368+
D0C447B31C02B1DE00DC1C4B /* btn_fliter_down@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "btn_fliter_down@2x.png"; sourceTree = "<group>"; };
2369+
D0C447B51C02B7C000DC1C4B /* icon_search_searchbar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_search_searchbar@2x.png"; sourceTree = "<group>"; };
23662370
E7A0469E1A47279E00528C12 /* Helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Helper.h; sourceTree = "<group>"; };
23672371
E7A0469F1A47279E00528C12 /* Helper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Helper.m; sourceTree = "<group>"; };
23682372
/* End PBXFileReference section */
@@ -4059,6 +4063,8 @@
40594063
7E8E59781B6F91C40083CA02 /* bubble */,
40604064
8EA6CF5F19E240C40076D59C /* btn_delete_tweetimage@2x.png */,
40614065
8B3516541B6CF69E0049BC45 /* icon_search_clock@2x.png */,
4066+
D0C447B51C02B7C000DC1C4B /* icon_search_searchbar@2x.png */,
4067+
D0C447B31C02B1DE00DC1C4B /* btn_fliter_down@2x.png */,
40624068
D09E6ACD1BF9CCCF009D37F8 /* fliter_square@2x.png */,
40634069
D09E6ABF1BF82DC6009D37F8 /* btn_setFrequent@2x.png */,
40644070
8EA6CF6319E240C40076D59C /* commentOrLikeBeginImg@2x.png */,
@@ -5146,6 +5152,7 @@
51465152
4EACB4411A2C448F0097ABB3 /* button_file_move_unable@2x.png in Resources */,
51475153
4E0BD8851B6C7F0A0061CAA6 /* mock_topicAdlist.geojson in Resources */,
51485154
8EA6D17419E240C40076D59C /* placeholder_coding_square_55@2x.png in Resources */,
5155+
D0C447B61C02B7C000DC1C4B /* icon_search_searchbar@2x.png in Resources */,
51495156
D09E6ADF1BF9DDDD009D37F8 /* info_Nav@2x.png in Resources */,
51505157
8E8F7B3119EF6306006BA8BD /* btn_privateMsg_stranger@2x.png in Resources */,
51515158
4E03AC9A1A5BDDF9002B000B /* STARTIMAGE.jpg in Resources */,
@@ -5242,6 +5249,7 @@
52425249
4EF17EE21B3C3112003CDD2D /* intro_tip_3@2x.png in Resources */,
52435250
4E6383D51B32665700D98648 /* project_item_mr_pr@2x.png in Resources */,
52445251
8E80296D19F4E23100A470A2 /* creator_image@2x.png in Resources */,
5252+
D0C447B41C02B1DE00DC1C4B /* btn_fliter_down@2x.png in Resources */,
52455253
8EA6D16719E240C40076D59C /* nav_project_activity@2x.png in Resources */,
52465254
4EFE8DAD1B394A0D004B7559 /* file_changeType_RENAME@2x.png in Resources */,
52475255
B9A00D7F1ACA3A05008BA008 /* ProjectSetting.storyboard in Resources */,

Coding_iOS/Controllers/RootControllers/Project_RootViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ - (void)viewDidLoad
107107
[searchBar.layer setBorderColor:[UIColor whiteColor].CGColor];  //设置边框为白色
108108
[searchBar sizeToFit];
109109
searchBar.delegate = self;
110+
// UITextField *searchField=[[[[searchBar subviews] firstObject] subviews] lastObject];
111+
// [(UIImageView*)searchField.leftView setImage:[UIImage imageNamed:@"icon_seach_searchbar"]];
112+
[searchBar setImage:[UIImage imageNamed:@"icon_search_searchbar"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
110113
[searchBar setPlaceholder:@"项目、任务、讨论等"];
111114
[searchBar setTintColor:[UIColor whiteColor]];
112115
[searchBar insertBGColor:[UIColor colorWithHexString:@"0x28303b"]];

Coding_iOS/Controllers/SearchViewController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ -(void)buildUI{
7979
[searchBar sizeToFit];
8080
[searchBar setTintColor:[UIColor whiteColor]];
8181
[searchBar insertBGColor:[UIColor colorWithHexString:@"0xffffff"]];
82+
// [searchBar setImage:nil forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
83+
// [searchBar setPositionAdjustment:UIOffsetMake(-10,0) forSearchBarIcon:UISearchBarIconSearch];
84+
// searchBar.searchTextPositionAdjustment=UIOffsetMake(10,0);
8285
[searchBar setHeight:30];
8386
searchBar;
8487
});
@@ -117,7 +120,6 @@ -(void)buildUI{
117120
if (!_searchDisplayVC) {
118121
_searchDisplayVC = ({
119122
AllSearchDisplayVC *searchVC = [[AllSearchDisplayVC alloc] initWithSearchBar:_mySearchBar contentsController:self];
120-
121123
//自定义uisearchbar 要在这里重新申明
122124
//需要重新调整下大小
123125
searchVC.searchBar.frame=CGRectMake(20,7, kScreen_Width-75, 30);
@@ -135,7 +137,6 @@ -(void)buildUI{
135137
searchVC;
136138
});
137139
}
138-
139140
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(popToMainVCAction)];
140141

141142

263 Bytes
Loading
927 Bytes
Loading

Coding_iOS/Views/Search/CategorySearchBar.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
@interface CategorySearchBar ()
1212
@property (copy,nonatomic)SelectBlock curBlock;
13-
@property (strong, nonatomic) UIButton *categoryBtn;
13+
@property (strong, nonatomic)UIButton *categoryBtn;
14+
@property (strong, nonatomic)UIButton *iconBtn;
1415
@end
1516

1617

@@ -21,14 +22,15 @@ -(void)layoutSubviews
2122
self.autoresizesSubviews = YES;
2223
//找到输入框 右移
2324
UITextField *searchField=[[[[self subviews] firstObject] subviews] lastObject];
24-
[searchField setFrame:CGRectMake(55,5,230,20)];
25-
25+
searchField.textAlignment=NSTextAlignmentLeft;
26+
[searchField setFrame:CGRectMake(58,5,225,20)];
2627
//
27-
// [(UIImageView*)searchField.leftView setImage:[UIImage imageNamed:@"tips_menu_icon_status"]];
28+
[(UIImageView*)searchField.leftView setFrame:CGRectZero];
2829
}
2930

3031
-(void)patchWithCategoryWithSelectBlock:(SelectBlock)block{
3132
[self addSubview:self.categoryBtn];
33+
[self addSubview:self.iconBtn];
3234
_curBlock=block;
3335
}
3436

@@ -44,6 +46,16 @@ -(UIButton*)categoryBtn{
4446
return _categoryBtn;
4547
}
4648

49+
-(UIButton*)iconBtn{
50+
if (!_iconBtn) {
51+
_iconBtn=[[UIButton alloc] initWithFrame:CGRectMake(50, 11, 8, 8)];
52+
[_iconBtn addTarget:self action:@selector(selectCategoryAction) forControlEvents:UIControlEventTouchUpInside];
53+
[_iconBtn setBackgroundImage:[UIImage imageNamed:@"btn_fliter_down"] forState:UIControlStateNormal];
54+
}
55+
return _iconBtn;
56+
}
57+
58+
4759

4860
#pragma mark -- event
4961
-(void)selectCategoryAction{

0 commit comments

Comments
 (0)