zoukankan      html  css  js  c++  java
  • IOS6和IOS7 显示一样的SearchBar

     if (isIOS7) {
            mySearchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
            mySearchBar.autocorrectionType =  UITextAutocorrectionTypeNo;
            mySearchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
            mySearchBar.keyboardType = UIKeyboardTypeDefault;
            mySearchBar.placeholder = @"全国地区(中文/拼音/区号/别名)                    ";
            mySearchBar.delegate =self;
            mySearchBar.tag = 100;
            mySearchBar.showsCancelButton =NO;//是否显示取消按钮
            [mySearchBar setBackgroundColor:MF_ColorFromRGB(229, 229, 229)];
            [[[[mySearchBar.subviews objectAtIndex:0] subviews] objectAtIndex:0] removeFromSuperview]; // 去掉搜索框背景
            [[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:MF_ColorFromRGB(181, 181, 181)]; // 修改placeholder textColor
            [self.view addSubview:mySearchBar];
        }
        else
        {
            mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 2, 320, 40)];
            mySearchBar.delegate = self;
            mySearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
            mySearchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
            mySearchBar.placeholder = @"全国地区(中文/拼音/区号/别名)";
            mySearchBar.keyboardType =  UIKeyboardTypeDefault;
            [mySearchBar setTranslucent:YES];
            mySearchBar.backgroundColor = MF_ColorFromRGB(229, 229, 229);
            [[mySearchBar.subviews objectAtIndex:0]removeFromSuperview];  // 去掉搜索框背景
            [[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:MF_ColorFromRGB(181, 181, 181)]; // 修改placeholder textColor
            [self.view addSubview:mySearchBar];
            
            // 替换UITextField背景图
            UITextField* searchField = nil;
            for (UIView* subview in mySearchBar.subviews) {
                if ([subview isKindOfClass:[UITextField class]])
                {
                    searchField = (UITextField*)subview;
                    break;
                }
            }
            searchField.background = [MF_PngWithSkin(DEFAULTS_SKIN, @"search_Bar_bgImg.png") stretchableImageWithLeftCapWidth:30 topCapHeight:30];
        }
  • 相关阅读:
    STM32的DMA
    STM32串口接收不定长数据原理与源程序(转)
    推挽与开漏
    开关量输入检测与输出的电路设计(转)
    理解一下单片机的I2C和SPI通信
    电阻桥的作用(转)
    为什么工业上用4到20毫安电流传输数据(转)
    Keil的标题“礦ision3" 的改变(转)
    epplus动态合并列数据
    npm脚本编译代码
  • 原文地址:https://www.cnblogs.com/joesen/p/3783226.html
Copyright © 2011-2022 走看看