• 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];
        }
  • 相关阅读:
    js某一时间加上指定时长
    .net mvc后端传值与前端js交互
    js里面的引用传递(数组赋值)
    datagrid的一些常见用法
    计算页面高度
    easyui datagrid导出
    导出highcharts图表到Csv(Xls)
    导出highcharts图表到pdf
    js导出table(简单粗暴)
    47.Permutations II
  • 原文地址:https://www.cnblogs.com/joesen/p/3783226.html
Copyright © 2020-2023  润新知