最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

IOS 開發(fā)之UISearchBar 詳解及實例

 更新時間:2016年12月05日 16:39:04   投稿:lqh  
這篇文章主要介紹了IOS 開發(fā)之UISearchBar 詳解及實例的相關(guān)資料,主要介紹 IOS UISearchBar的使用,附有實例代碼,需要的朋友可以參考下

IOS UISearchBar 詳解

iPhone開發(fā)之UISearchBar學(xué)習(xí)是本文要學(xué)習(xí)的內(nèi)容,主要介紹了UISearchBar的使用,不多說,我們先來看詳細內(nèi)容。關(guān)于UISearchBar的一些問題。

1、修改UISearchBar的背景顏色

UISearchBar是由兩個subView組成的,一個是UISearchBarBackGround,另一個是UITextField. 要IB中沒有直接操作背景的屬性。方法是直接將 UISearchBarBackGround移去 

seachBar=[[UISearchBar alloc] init]; 
seachBar.backgroundColor=[UIColor clearColor]; 
for (UIView *subview in seachBar.subviews)  
{  
if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) 
    {  
[subview removeFromSuperview];  
break; 
}  
} 

第二種解決的方法:

[[searchbar.subviews objectAtIndex:0]removeFromSuperview]; 

2、

UISearchBar* m_searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 44, 320, 41)]; 
m_searchBar.delegate = self; 
m_searchBar.barStyle = UIBarStyleBlackTranslucent; 
m_searchBar.autocorrectionType = UITextAutocorrectionTypeNo; 
m_searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone; 
m_searchBar.placeholder = _(@"Search"); 
m_searchBar.keyboardType = UIKeyboardTypeDefault; 
//為UISearchBar添加背景圖片 
UIView *segment = [m_searchBar.subviews objectAtIndex:0]; 
UIImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Images/search_bar_bg.png"]]; 
[segment addSubview: bgImage]; 
//<---背景圖片 
[self.view addSubview:m_searchBar]; 
[m_searchBar release]; 

3:取消UISearchBar調(diào)用的鍵盤

[searchBar resignFirstResponder]; 

添加UISearchBar的兩種方法:

代碼

UISearchBar *mySearchBar = [[UISearchBar alloc] 
initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];     
 mySearchBar.delegate = self;     
 mySearchBar.showsCancelButton = NO;     
 mySearchBar.barStyle=UIBarStyleDefault;     
 mySearchBar.placeholder=@"Enter Name or Categary";      
mySearchBar.keyboardType=UIKeyboardTypeNamePhonePad;      
[self.view addSubview:mySearchBar];     
 [mySearchBar release];  

在 tableview上添加:  

代碼 

 //add Table 
    UITableView *myBeaconsTableView = [[UITableView alloc]  
                      initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-40)  
                       style:UITableViewStylePlain]; 
    myBeaconsTableView.backgroundColor = [UIColor whiteColor]; 
    myBeaconsTableView.delegate=self; 
    myBeaconsTableView.dataSource=self; 
    [myBeaconsTableView setRowHeight:40]; 
    // Add searchbar  
    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 40)]; 
    searchBar.placeholder=@"Enter Name"; 
    searchBar.delegate = self; 
    myBeaconsTableView.tableHeaderView = searchBar; 
    searchBar.autocorrectionType = UITextAutocorrectionTypeNo; 
    searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone; 
    [searchBar release]; 
    [self.view addSubview:myBeaconsTableView]; 
    [myBeaconsTableView release]; 

小結(jié):iPhone開發(fā)之UISearchBar學(xué)習(xí)的內(nèi)容介紹完了,希望本文對你有所幫助

相關(guān)文章

  • iOS UISegmentControl實現(xiàn)自定義分欄效果

    iOS UISegmentControl實現(xiàn)自定義分欄效果

    這篇文章主要為大家詳細介紹了iOS UISegmentControl實現(xiàn)自定義分欄效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • iOS自定義可展示、交互的scrollView滾動條

    iOS自定義可展示、交互的scrollView滾動條

    這篇文章主要為大家詳細介紹了iOS自定義可展示、交互的scrollView滾動條,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-04-04
  • iOS中block的定義與使用

    iOS中block的定義與使用

    蘋果官方文檔聲明,block是objc對象。下面這篇文章主要給大家介紹了關(guān)于iOS中block的定義與使用,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • IOS  多線程GCD詳解

    IOS 多線程GCD詳解

    這篇文章主要介紹了IOS 多線程GCD詳解的相關(guān)資料,需要的朋友可以參考下
    2016-09-09
  • IOS 詳解socket編程[oc]粘包、半包處理

    IOS 詳解socket編程[oc]粘包、半包處理

    這篇文章主要介紹了IOS 詳解socket編程[oc]粘包、半包處理的相關(guān)資料,需要的朋友可以參考下
    2017-02-02
  • iOS彈幕組件LNDanmakuMaster的具體使用

    iOS彈幕組件LNDanmakuMaster的具體使用

    這篇文章主要介紹了iOS彈幕組件LNDanmakuMaster的具體使用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • swift 單例的實現(xiàn)方法及實例

    swift 單例的實現(xiàn)方法及實例

    這篇文章主要介紹了swift 單例的實現(xiàn)方法及實例的相關(guān)資料,需要的朋友可以參考下
    2017-07-07
  • 詳解iOS集成融云SDK即時通訊整理

    詳解iOS集成融云SDK即時通訊整理

    這篇文章主要介紹了詳解iOS集成融云SDK即時通訊整理,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • ios系統(tǒng)下刪除文件的代碼

    ios系統(tǒng)下刪除文件的代碼

    本文給大家總結(jié)了幾則在IOS系統(tǒng)下刪除文件的代碼,十分的實用,有需要的小伙伴可以參考下。
    2015-05-05
  • iOS下拉選擇菜單簡單封裝

    iOS下拉選擇菜單簡單封裝

    這篇文章主要為大家詳細介紹了iOS下拉選擇菜單封裝代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11

最新評論

岐山县| 永丰县| 金塔县| 汕头市| 永修县| 嘉义市| 拉萨市| 神池县| 巢湖市| 赣榆县| 鱼台县| 宁武县| 昌吉市| 门头沟区| 高安市| 甘谷县| 翼城县| 舞钢市| 衡阳市| 华坪县| 罗江县| 石门县| 万州区| 仙桃市| 浠水县| 宁波市| 夏河县| 永平县| 昌邑市| 红河县| 电白县| 兰考县| 宜良县| 潮州市| 海晏县| 阜阳市| 金溪县| 德阳市| 古田县| 焉耆| 英超|