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;
    }
  • 相关阅读:
    2015 ACM/ICPC Asia Regional Changchun Online HDU 5444 Elven Postman【二叉排序树的建树和遍历查找】
    JDBC连接MySQL数据库
    MySQL实习训练1
    I Hate It
    Just a Hook
    Mayor's posters
    asd的甩锅计划
    程序员的恋情
    Radical and array
    Highways
  • 原文地址:https://www.cnblogs.com/seer/p/5162509.html
Copyright © 2011-2022 走看看