I have the following snippet to remove the background from a UISearchBar:
for (UIView *subview in self.searchDisplayController.searchBar.subviews)
{
if ([subview isKindOfClass:NSClassFromString(#"UISearchBarBackground")])
{
[subview removeFromSuperview];
break;
}
}
However, if the device is rotated to landscape a black background appears behind the search bar. Any ideas how to fix it? I'm not exactly sure if this is undocumented.
Thanks!
I just ran across this problem and found little help searching. Unfortunately, removing the feature was not an option so I had to figure it out. It seems as the the UISearchBar view has a background that goes black when you change orientation. So my code now looks like this:
[searchBar setBackgroundColor:[UIColor clearColor]];
for (UIView *subview in searchBar.subviews)
{
if ([subview isKindOfClass:NSClassFromString(#"UISearchBarBackground")])
[subview removeFromSuperview];
}
Given the undocumented nature, I removed the feature. Appears to be a bug due to the undocumented call.
got it ....
open the interface builder under searchbar attributes in view, Mode is set as 'Redraw' set it to scaleToFill
Related
I have a XIB with a UIWebView with Alpha = 1.0, Background set to Clear Color and Opaque is not set. On this XIB I setup an image as background with this code:
The UIWebView is showing an static html:
<html><head></head><body style=\"margin:0 auto;text-align:center;background-color: transparent; color:white\">...</body></html>
Any Solution?
try this...
webViewFirstTab.opaque=NO;
for (UIView* subView in [webViewFirstTab subviews])
{
if ([subView isKindOfClass:[UIScrollView class]]) {
for (UIView* shadowView in [subView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
}
}
This does not work for me on iOS6 or iOS7. The UIWebView holds a _UIWebViewScrollView which holds a UIWebBrowserView. Setting the backGround color of all 3 views to clear color does not result in a transparent background. I also have the html like this:
Anybody got this to work on iOS 6 or 7?
I have a dark background with a UITableView on top of it. By default the section index is semi-transparent with a dark text colour. I'd like to change the text colour for the section index to the same colour as I have made the UITableViewCell title label. I have read around a bit and it seems you have to subclass the UITableView? How do I do this?
Since iOS 6 you have the possibility to do it like:
searchTable.sectionIndexColor = [UIColor blackColor];
To solve this I used the following in viewDidAppear:
for (UIView *subView in [self.view subviews])
{
if ([[[subView class] description] isEqualToString:#"UITableViewIndex"])
{
[subView performSelector:#selector(setIndexColor:) withObject:[UIColor whiteColor]];
}
}
Since it's not documented, it has to be through a selector.
As of iOS 6.0 there are two methods that allow you to change the color of the section indexes and the background shown when you drag the scrubber.
if ([tableView respondsToSelector:#selector(setSectionIndexColor:)]) {
tableView.sectionIndexColor = ... // some color
tableView.sectionIndexTrackingBackgroundColor = ... // some other color
}
Of course this will only execute if the device has 6.0+. With any older iOS, nothing will change.
I have used this code to remove background behind searchbar but when I rotate the view to Landscape or launch the application in landscape view a black container is displayed around searchbar
for (UIView *searchSubview in mySearchBar.subviews) {
NSLog(#"Subview: %#", searchSubview);
if ([searchSubview isKindOfClass:NSClassFromString(#"UISearchBarBackground")]) {
//[searchSubview removeFromSuperview];
[searchSubview setAlpha:0.0];
//[searchSubview setBackgroundColor:[UIColor clearColor]];
//break;
}
}
Please enlighten me on this. I tried to implement this code in willRotate, shouldRotate and didRotate methods but problem persist. Please enlighten me on this.
Regards
Ankit
got it ....
open the interface builder
under searchbar attributes in view, Mode is set as 'Redraw' set it to scaleToFill
I think this shouldn't be a big problem, but I can't find the solution on my own. As always :p I have an UIWebView that has background color set to clearColor but when I try to scroll down too much I get the "bouncing area" above loaded HTML in dark gray color. I would like to change this to transparent/white. Is there any way of changing this?
Digression: I read that classes inheriting UIScrollView can have property bounce = NO and then they won't show the bouncing area at all. Even if UIWebView was inheriting that class I wouldn't like to stop it from bouncing, just "bounce it in white" so to speak...
Thanks a lot,
Luka
Take a look at the following answer
Remove gradient background from UIWebView?
Set the webview's background colour and set opaque to NO:
[self.webView setBackgroundColor:[UIColor whiteColor]];
[self.webView setOpaque:NO];
Or try setting clear color as background:
[self.webView setBackgroundColor:[UIColor clearColor]];
[self.webView setOpaque:NO];
#Ladislav: thanks for pointing me to the right subject :)
Now, the following post Remove gradient background from UIWebView? is exactly what I needed, so I am sorry I opened the new thread. I searched the forum but since there is no name for this gradient, bounce background or background I couldn't find it earlier.
The summary would be:
1.Setting the backgroundColor of web view to clearColor !in code! cause in interface builder is not producing the wanted result.
myWebView.backgroundColor = [UIColor clearColor];
this line will only make the "overscroll" background look lighter, but to remove it totally (make it transparent/white) we need to hide all imageViews found in subViews of our myWebView:
for (UIView* subView in [self.myWebView subviews])
{
if ([subView isKindOfClass:[UIScrollView class]]) {
for (UIView* shadowView in [subView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
}
}
Thanks everyone, I wish you a great weekend
Is there a way to get a black keyboard? The default one is bluish. And the Alert style one is semi-transparent black. I was wondering if it was possible to have the keyboard black, e.g. non transparent. Or do I have to pull up a black view behind the keyboard to reduce the transparency effect?
The short answer is, NO. The only two keyboards you can display are the normal and alert style keyboards.
There are ways to hack around, get the ui keyboard and change it's composition. I wouldn't recommend doing this as it will 1) likely make have your app rejected from the app store and 2) likely break the next time an iOS revision comes around.
Seems like putting a black or white view behind the keyboard should work for application. In this case I would recommend looking here for a way to animate that black view up below the keyboard.
As Ben states above you can just use one of these two values:
[textView setKeyboardAppearance:UIKeyboardAppearanceAlert];
[textView setKeyboardAppearance:UIKeyboardAppearanceDefault];
Here is code to remove the UIKeyboard background by hiding it. Feel free to modify it to tint the UIKeyboard:
-(NSArray*)subviewsOfView:(UIView*)view withType:(NSString*)type{
NSString *prefix = [NSString stringWithFormat:#"<%#",type];
NSMutableArray *subviewArray = [NSMutableArray array];
for (UIView *subview in view.subviews) {
NSArray *tempArray = [self subviewsOfView:subview withType:type];
for (UIView *view in tempArray) {
[subviewArray addObject:view];
}
}
if ([[view description]hasPrefix:prefix]) {
[subviewArray addObject:view];
}
return [NSArray arrayWithArray:subviewArray];
}
-(void)removeKeyboardBackground{
for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) {
for (UIView *keyboard in [keyboardWindow subviews]) {
for (UIView *view in [self subviewsOfView:keyboard withType:#"UIKBBackgroundView"]) {
view.hidden=YES;
}
}
}
}
Just call [self removeKeyboardBackground] after you received a NSNotification for UIKeyboardDidShowNotification. Do whatever you want with the background view by replacing view.hidden=YES; with whatever you would like.