---
title: "让UISearchBar 的背景消失"
author: "squll369"
date: "2015-12-17T23:37:08Z"
tags: []
categories: ["移动开发"]
slug: "uisearchbar"
draft: false
lastmod: "2015-12-17T23:37:08Z"
id: 2264907
url: "https://squll369.iteye.com/blog/2264907"
---

还是这段代码处理起来比较简单～～  

 

    for (UIView \*view in\_searchBar.subviews) {

        // for before iOS7.0

        if (\[view isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {

            \[view removeFromSuperview];

            break;

        }

        // for later iOS7.0(include)

        if (\[view isKindOfClass:NSClassFromString(@"UIView")] && view.subviews.count &gt; 0) {

            \[\[view.subviewsobjectAtIndex:0] removeFromSuperview];

            break;

        }

 

    }