美文网首页iOS高阶UI相关iOS Developer
IOS UISearchBar 去掉背景颜色

IOS UISearchBar 去掉背景颜色

作者: JakieZhang | 来源:发表于2016-12-03 10:56 被阅读65次

    _searchBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:_searchBar.bounds.size];

    /** 取消searchBar背景色*/

    - (UIImage *)imageWithColor:(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();returnimage;

    }

    相关文章

      网友评论

        本文标题:IOS UISearchBar 去掉背景颜色

        本文链接:https://www.haomeiwen.com/subject/yiqcmttx.html