欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

IOS UISearchBar 詳解

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

1、修改UISearchBar的背景顏色

UISearchBar是由兩個(gè)subView組成的,一個(gè)是UISearchBarBackGround,另一個(gè)是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)容介紹完了,希望本文對(duì)你有所幫助

相關(guān)文章

  • iOS開發(fā)--仿新聞首頁效果WMPageController的使用詳解

    iOS開發(fā)--仿新聞首頁效果WMPageController的使用詳解

    這篇文章主要介紹了iOS開發(fā)--仿新聞首頁效果WMPageController的使用詳解,詳解的介紹了iOS開發(fā)中第三方庫WMPageController控件的使用方法,有需要的可以了解下。
    2016-11-11
  • IOS給圖片添加水?。▋煞N方式)

    IOS給圖片添加水?。▋煞N方式)

    為了防止自己辛苦做的項(xiàng)目被別人盜走,采取把圖片添加水印,在此表示圖片的獨(dú)一無二。加水印不是要在上面添加上幾個(gè)Label,而是我們要把字畫到圖片上成為一個(gè)整體,下面這篇文章主要介紹IOS給圖片添加水印,有需要的小伙伴可以來參考下
    2015-08-08
  • iOS提取APP中的圖片資源的方法

    iOS提取APP中的圖片資源的方法

    這篇文章主要介紹了iOS提取APP中的圖片資源的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-11-11
  • 深入分析iOS應(yīng)用中對(duì)于圖片緩存的管理和使用

    深入分析iOS應(yīng)用中對(duì)于圖片緩存的管理和使用

    這篇文章主要介紹了iOS應(yīng)用中對(duì)于圖片緩存的管理和使用,實(shí)例代碼為傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2016-04-04
  • iOS15適配小結(jié)

    iOS15適配小結(jié)

    本文主要介紹了iOS15適配小結(jié),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • iOS實(shí)現(xiàn)卡片式滾動(dòng)效果 iOS實(shí)現(xiàn)電影選片效果

    iOS實(shí)現(xiàn)卡片式滾動(dòng)效果 iOS實(shí)現(xiàn)電影選片效果

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)卡片式滾動(dòng)效果,實(shí)現(xiàn)電影選片效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-02-02
  • iOS開發(fā)教程之UIView和UIViewController的生命周期詳解

    iOS開發(fā)教程之UIView和UIViewController的生命周期詳解

    UIViewController是IOS程序中的一個(gè)重要組成部分,下面這篇文章主要給大家介紹了關(guān)于iOS開發(fā)教程之UIView和UIViewController的生命周期的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2018-04-04
  • iOS如何讓tableview支持不同種類的cell詳解

    iOS如何讓tableview支持不同種類的cell詳解

    這篇文章主要給大家介紹了關(guān)于iOS如何讓tableview支持不同種類的cell的相關(guān)資料,文中通過示例代碼詳細(xì)的給大家介紹了實(shí)現(xiàn)的兩種方法,對(duì)各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-08-08
  • ios下移動(dòng)文件方法匯總

    ios下移動(dòng)文件方法匯總

    這篇文章主要給大家匯總了一下ios下移動(dòng)文件方法,從簡(jiǎn)單到復(fù)雜,十分的實(shí)用,有需要的小伙伴可以參考下。
    2015-05-05
  • touchesBegan: withEvent: 不執(zhí)行解決

    touchesBegan: withEvent: 不執(zhí)行解決

    這篇文章主要介紹了touchesBegan: withEvent: 不執(zhí)行解決的相關(guān)資料,需要的朋友可以參考下
    2016-12-12

最新評(píng)論