欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

如何修改系統(tǒng)UISearchBar的樣式

        自從接觸iOS快一年多的時(shí)間了,感覺自己還是菜鳥一枚,最近在整理自己的開發(fā)過程中得點(diǎn)點(diǎn)滴滴,想通過博客的形式記錄下來。本博客會(huì)陸續(xù)添加內(nèi)容,鑒于本人水平有限,如有錯(cuò)誤,請(qǐng)給與指正,感激不盡。

專注于為中小企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)應(yīng)縣免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000+企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

        修改UISearchBar的樣式,網(wǎng)上也有很多種,也都大同小異,本篇也不例外,但確實(shí)很實(shí)用,廢話不多說,上代碼:

        1.UISearchBar帶有背景顏色的

         if (!_searchBar) {
        _searchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(10, 20, self.view.frame.size.width-20, 40)];
        _searchBar.placeholder=@"搜索";
        _searchBar.delegate=self;
        //searchBar的背景顏色
        //1.
        [_searchBar setBackgroundColor:[UIColor orangeColor]];
        //2.關(guān)鍵
        [[[_searchBar.subviews objectAtIndex:0].subviews objectAtIndex:0] removeFromSuperview];
        
        
        //顯示取消按鈕
        _searchBar.showsCancelButton=YES;
        
        UIButton *cancelBtn=[_searchBar valueForKey:@"_cancelButton"];
        [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
        cancelBtn.titleLabel.font=[UIFont systemFontOfSize:14];
        [cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        //設(shè)置光標(biāo)的顏色
        _searchBar.tintColor=[UIColor redColor];
        
        
        UITextField *searchFiled=[_searchBar valueForKey:@"_searchField"];
        //設(shè)置處于編輯狀態(tài)
        [searchFiled becomeFirstResponder];
        
        //輸入文本的顏色
        searchFiled.textColor=[UIColor greenColor];
        
        //輸入文本字體的大小
        searchFiled.font=[UIFont systemFontOfSize:14];
        
        //輸入框的圓角設(shè)置
        searchFiled.layer.cornerRadius=10;
        searchFiled.layer.masksToBounds=YES;
        
        //輸入框里面的背景顏色
        searchFiled.backgroundColor=[UIColor whiteColor];
        
        //提示文本的顏色
        [searchFiled setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
        
        self.cancelField=searchFiled;
        
        //輸入框里的圖標(biāo)
        [_searchBar setImage:[UIImage p_w_picpathNamed:@"boy.jpg"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];

        [self.view addSubview:_searchBar]       

      2.UISearchBar不帶背景顏色的

       //    如果不要searchBar的背景顏色
//    1.關(guān)鍵
    [_searchBar setBackgroundColor:[UIColor clearColor]];
    [[[_searchBar.subviews objectAtIndex:0].subviews objectAtIndex:0] removeFromSuperview];
//    2.
    UIView *searchView=[[UIView alloc]initWithFrame:CGRectMake(10, 20, self.view.frame.size.width-20, 40)];
    searchView.layer.cornerRadius=10;
    searchView.layer.borderColor=[UIColor orangeColor].CGColor;
    searchView.layer.borderWidth=1.f;
    [self.view addSubview:searchView];
    [self.view addSubview:_searchBar];

#pragram--

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    NSLog(@"實(shí)時(shí)監(jiān)控文字輸入");
}


- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    NSLog(@"點(diǎn)擊搜索按鈕");
}


- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
    NSLog(@"點(diǎn)擊取消按鈕");
    [self.cancelField resignFirstResponder];
}

當(dāng)前名稱:如何修改系統(tǒng)UISearchBar的樣式
本文網(wǎng)址:http://chinadenli.net/article4/gsghoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作電子商務(wù)標(biāo)簽優(yōu)化關(guān)鍵詞優(yōu)化網(wǎng)站改版企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)