城市選擇之搜尋框

2021-09-07 04:04:45 字數 2375 閱讀 1161

新專案要做城市選擇,效果圖出來,用系統的搜尋框達不到效果圖的效果,設定searchbarstyle屬性時,uisearchbarstyledefault時設定bartintcolor後邊框會有黑線,設定uisearchbarstyleminimal時無黑線單文字框顏色不符合要求。所以就自定義了下。先看下效果圖

上面兩個效果圖的區別就是下面的圖有個城市和。所以就封裝到乙個類中。只是textfield的leftview變化。還有個問題就是城市名長短不一,設定城市的時候要進行重繪,所以我在set城市名的時候呼叫重繪方法。具體**如下:

//

//locationdemo

////

created by city--online on 15/11/30.

////

#import

typedef

void(^leftbtnclickblock)();

@inte***ce

searchtextfield : uitextfield

@property (nonatomic,strong) nsstring *lefttitle;

@property (nonatomic,copy) leftbtnclickblock btnclickblock;

-(instancetype)initnolefttitlewithframe:(cgrect)frame;

@end

//

//locationdemo

////

created by city--online on 15/11/30.

////

#import

"searchtextfield.h

"#import

"global.h

"@inte***ce

searchtextfield ()

@property (nonatomic,strong) uibutton *leftbtn;

@property (nonatomic,strong) uiimageview *leftimgview;

@property (nonatomic,strong) uiimageview *searchimgview;

@property (nonatomic,assign) bool isnolefttitle;

@end

@implementation

searchtextfield

-(instancetype)initnolefttitlewithframe:(cgrect)frame

-(instancetype)initwithframe:(cgrect)frame

return

self;

}-(void

)layoutsubviews

else

; cgrect titleframe=[_lefttitle boundingrectwithsize:cgsizemake(maxfloat, maxfloat) options:nsstringdrawinguseslinefragmentorigin attributes:attributes context:nil];

self.leftview.frame=cgrectmake(0, 0, 62+titleframe.size.width, self.frame.size.height);

_leftbtn.frame=cgrectmake(10, 0, titleframe.size.width+22

, self.frame.size.height);

[_leftbtn settitle:_lefttitle forstate:uicontrolstatenormal];

_leftimgview.frame=cgrectmake(titleframe.size.width+10, (self.frame.size.height-5)/2, 10, 5

);

_searchimgview.frame=cgrectmake(titleframe.size.width+37, (self.frame.size.height-15)/2, 15, 15

); }

}-(void)btnclickhandle:(id

)sender

-(void)setlefttitle:(nsstring *)lefttitle

@end

jquery實現 城市選擇框

jquery實現 城市選擇框。城市單選框 1 引入js和css 2 指定輸入框 function 3 輸入框 城市 4 修改city.js檔案 在檔案最後 function else ajax cache false,預設為true。設定為 false 將不會從瀏覽器快取中載入請求資訊。dataty...

選擇框實現搜尋過濾

qryall this.service.getallcustomer params subscribe data 搜尋 templist customerfilter no 要把qryall 放到oninit 中,剛載入時就執行。splice 方法用於新增或刪除陣列中的元素。語法 array.spl...

模擬移動端輸入框輸入搜尋城市搜尋功能

1.模擬移動端輸入框輸入搜尋城市搜尋功能 2.具體實現功能步驟如下 過程如下 搜尋功能實現過程 1.通過父元件將cities物件中的資料傳遞給搜尋框子元件 2.雙向繫結搜尋框中的資料keyword 3.監聽搜尋框中資料的改變 4.設定定時器,當搜尋框中的輸入發生變化時通過迴圈來匹配到搜尋的資料 4....