zoukankan      html  css  js  c++  java
  • IOS 改变UISearchBar的背景色

    之前网上提供的方法试了很多种  都不能很好的去掉背景色  ,修改背景色方法如下:

    searchbar.barStyle = UIBarStyleBlackTranslucent;

        searchbar.autocorrectionType = UITextAutocorrectionTypeNo;

        searchbar.autocapitalizationType = UITextAutocapitalizationTypeNone;

        searchbar.keyboardType = UIKeyboardTypeDefault;

    searchbar.backgroundImage = [self SearchImageWithColor:[UIColor clearColor] size:searchbar.bounds.size];
     
    定义一个函数  
    //取消searchbar背景色
    - (UIImage *)SearchImageWithColor:(UIColor *)color size:(CGSize)size
    {
        CGRect rect = CGRectMake(0, 0, size.width, size.height);
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
          
        CGContextSetFillColorWithColor(context, [color CGColor]);
        CGContextFillRect(context, rect);
          
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
          
        return image;
    }
  • 相关阅读:
    字符串,列表和元组-3
    数据和表达式-2
    python3.6.2(32位)的安装-1
    HTTP协议
    bug无法重现
    当开发说不是BUG时怎么办
    Python流程分类初试
    私有,封装
    Python继承
    编译型语言和解释型语言
  • 原文地址:https://www.cnblogs.com/seer/p/5162509.html
Copyright © 2011-2022 走看看