我知道已經晚了,但參考這裏是
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^ { 的CGRect RECT = CGRectMake(0.0F,0.0F,1.0F,1.0F); UIGraphicsBeginImageContext(rect.size); 的UIImage *圖像=零; CGContextRef context = UIGraphicsGetCurrentContext(); (上下文)CGContextSetFillColorWithColor(context,[UIColor clearColor] .CGColor); CGContextFillRect(context,rect); image = UIGraphicsGetImageFromCurrentImageContext(); } UIGraphicsEndImageContext();在iOS系統7中的另外的UIView添加到的UISearchBar
dispatch_async(dispatch_get_main_queue(), ^{
self.backgroundImage = image;
});
});
由於外觀API,視圖層次可能已更改。在'-viewDidLoad'中設置一個斷點,並在程序暫停時,在控制檯中輸入'po [searchBar recursiveDescription]'來獲取整個視圖層次結構的列表,包括私有類名稱。 – 2012-01-12 18:33:22
@Mark Adams - 不知道,但以編程方式創建UIsearchBar,而不是nib爲我工作 – iOSPawan 2012-01-12 18:57:41
如果您正在執行'-initWithFrame:'中的代碼,那很明顯。從nib加載使用'-initWithCoder:'初始化程序。 – 2012-01-12 19:02:19