How to change the default gray background color of UIWebView to an image?
This is how you can set the background image:
self.webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:imagePath]];
Related
I'm new in xamarin(start using 2 week), now I need do a background Image wtih navigation bar like below picture? how can I do it?
You need to add an UIImage in your UIViewController (filling whole or only top of ViewController) setting your UINavigationBar to a clear color with
YourNavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
YourNavigationBar.ShadowImage = new UIImage();
YourNavigationBar.Translucent = true;
YourNavigationBar.BackgroundColor = UIColor.Clear;
To reset UINavigationBar transparency you have to use:
YourNavigationBar.SetBackgroundImage(null, UIBarMetrics.Default);
As in subject, I am wondering if right now in React Native is an option to change color of inactive TabBar icon from default gray to custom color? With or without using react-native-vector-icons
I found solution, but your icon should be in "inactive" color. To achieve this go to RTCTabBarItem.m and change first line in method setIcon:
- (void)setIcon:(UIImage *)icon
{
_icon = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
if (_icon && _systemIcon != NSNotFound) {
_systemIcon = NSNotFound;
UITabBarItem *oldItem = _barItem;
_barItem = [UITabBarItem new];
_barItem.title = oldItem.title;
_barItem.imageInsets = oldItem.imageInsets;
_barItem.selectedImage = oldItem.selectedImage;
_barItem.badgeValue = oldItem.badgeValue;
}
self.barItem.image = _icon;
}
Then in all TabBarIOS.Item add field selectedIcon with the same url as in icon (that's no matter), set tintColor of TabBarIOS to "active" color and that's all! TabBar will be rendered with default icon color (inactive), and active icon will be in tintColor. I think that TabBar field renderAsOriginal should do this, but it not works. After all I found this solution on github https://github.com/facebook/react-native/issues/3083
Another solution (may not works in some cases):
in xCode find file RCTTabBar.m (cmd + shift + f)
find - (instancetype)initWithFrame:(CGRect)frame
add before return self:
[[UIView appearanceWhenContainedIn: [UITabBar class], nil] setTintColor: [UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor: [UIColor greenColor]];
Restart Simulator/Device
In code redColor is color of inactive buttons, and greenColor is color of active button. For more details checkout this Unselected UITabBar color?
Edit: I found great tool if you want convert RGB to UIColor http://uicolor.xyz/
Does anybody know, how I can make the UINavigationBar solid black in IOS7? Default it is white, and I need it black.
If you're targeting only iOS 7 you can use:
[[UINavigationBar appearance] setBarTintColor:(UIColor *)];
Here is one way that creates a black UIImage programmatically and sets it for the UINavigationBar's appearance:
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 568, 44)];
background.backgroundColor = [UIColor blackColor];
UIGraphicsBeginImageContext(background.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[background.layer renderInContext:context];
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];
found it by myself. Go into storyboard-designer, select the ViewController, go to attribute inspector and change Top Bar from inferred to 'Opaque black navigation bar'
I wonder if is possible to remove background color on selected Item of a UITabBar
I want to remove gray background of UITabBar button. Is it possible ??
I put selected and normal image on delegate method:
- (void)tabBar:(UITabBar *)theTabBar didSelectItem:(UITabBarItem *)item{
NSUInteger indexOfTab = [[theTabBar items] indexOfObject:item];
[item setFinishedSelectedImage:[UIImage imageNamed:
[NSString stringWithFormat:#"%u_btnH.png",indexOfTab]]
withFinishedUnselectedImage:[UIImage imageNamed:
[NSString stringWithFormat:#"%u_btn.png",indexOfTab]]
];
}
My custom TabBarItem image are 0_btn.png for normal and 0_btnH.png for selected/hover image
Just set the selectionIndicatorImage to an empty image:
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage alloc]];
Is it possible to place an image in the UIWebView background instead of that gray default color. If yes then how?
Did it by myself.
self.webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:backgroundImage]];
In your viewDidLoad please Add this code for loading image at startup
[webView setOpaque:NO];
webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:#"night.jpg"]];
self.webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:imagePath]];