我知道已经晚了,但参考这里是
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