我正试图在iOS 7中删除UISearchBar的边框.在iOS 6中,它工作正常.我以编程方式创建了UISearchBar.我几乎尝试了Stack Overflow和Google的所有内容.
SearchBar正在寻找

我想要实现的目标

我尝试了下面提到的所有这些东西
searchBar.layer.borderWidth = 1;
searchBar.layer.borderColor = [[UIColor whiteColor] CGColor];
Run Code Online (Sandbox Code Playgroud)
和
for (id img in searchBar.subviews)
{
if ([img isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
{
[img removeFromSuperview];
}
}
Run Code Online (Sandbox Code Playgroud)
和
for (UIView *sub in self.tableView.tableHeaderView.subviews) {
if ([sub isKindOfClass:[UIImageView class]]) {
sub.hidden = YES;
}
}
Run Code Online (Sandbox Code Playgroud)
但仍然没有成功.
我试图找出这个问题,但在做了我在OS或谷歌上发现的所有事情后失败了.问题是,当我转换UIImage为NSData使用UIImageJPEGRepresentation或UIImagePNGRepresentation它将内存大小增加到30Mb(相信我或不相信).
这是我的代码
myImage= image;
LoginSinglton*loginObj = [LoginSinglton sharedInstance];
NSError *error;
NSData *pngData = UIImageJPEGRepresentation(image, scaleValue); //scaleVale is 1.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
self.imageCurrentDateAndTime =[self getTimeAndDate];
self.filePathAndDirectory = [documentsPath stringByAppendingPathComponent:@"Photos Dir"];
NSLog(@"Documents path %@",self.filePathAndDirectory);
if (![[NSFileManager defaultManager] createDirectoryAtPath:self.filePathAndDirectory
withIntermediateDirectories:NO
attributes:nil
error:&error])
{
NSLog(@"Create directory error: %@", error);
}
self.imageName= [NSString stringWithFormat:@"photo-%@-%@.jpg",loginObj.userWebID,self.imageCurrentDateAndTime];
NSString *filePath = [self.filePathAndDirectory stringByAppendingPathComponent:self.imageName];
[pngData writeToFile:filePath atomically:YES]; //Write the file …Run Code Online (Sandbox Code Playgroud)