I Have this Image for my UITabBar:
And this is how i add it to the Tab:
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"NewTabBar.png"]];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:#"tabbar_selection.png"]];
And i noticed that when i rotate the device to landscape mode the image won't re-size to all the screen.
How i can re-size it?
Try to incorporate resizableimageWithCapInsets:, like this:
[[UITabBar appearance] setSelectionIndicatorImage:[[UIImage imageNamed:#"tabbar_selection.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 5, 5, 5)]];
Try to
self.tabBarController.tabBar.autoresizingMask=UIViewAutoresizingFlexibleRightMargin || UIViewAutoresizingFlexibleLeftMargin;
Or experiment with it;
Related
I am using UITabbarController in my application and also I set the frame to it so that tabbar is display in center. I am so change color and image of tabbar but I want to remove the small edge its not clear how can i clear that color become white.
Code: [[UITabBar appearance] setShadowImage : [UIImage imageNamed:#"white.png"]];
Another option is, add
#import <QuartzCore/QuartzCore.h>
FrameWork and use
self.tabBarController.tabBar.layer.borderWidth = 0.50;
self.tabBarController.tabBar.layer.borderColor = self.tabBarController.tabBar.tintColor.CGColor;
add clipsToBounds and set to YES.
[[UITabBar appearance] setShadowImage:[UIImage imageNamed:#"transparentImage.png"]];
Try this with a transparent image.
or
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
These all are responsible for it. Try with second approach, as first is not working for you.
In my application i add custom navigation image while adding the remaining part of the image shows black in color, i used following code,
UIImage *image = [UIImage imageNamed: #"navbar.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarStyleDefault];
i want to show the back ground color in the in the black color part.what should change in code?
Please Try Following may be it works fine.
UINavigationBar *navBar = [[self navigationController] navigationBar];
UIImage *backgroundImage = [UIImage imageNamed:#"navbar.png"];
[navBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
Edited
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navbar.png"] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"navbar.png"]];
I'm using very useful library (class SCNavigationBar) for styling navigaitonBar, download it here
It supports all orientations, it works with no problem in my many apps.
I am using UITabBarController and want to add image to it, a whole image to tab bar, not to any tab item. Is it possible, can anyone guide.
Thanks in advance.
Try this. May be it help
UIImage *tabBackground = [[UIImage imageNamed:#"Your Image"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Set background for all UITabBars
[[UITabBar appearance] setBackgroundImage:tabBackground];
// Set background for only this UITabBar
[[tabBarController tabBar] setBackgroundImage:tabBackground];
If you are using iOS 5 or greater you can use setBackgroundImage:
UITabBar *yourtabBar = [yourtabController tabBar];
[yourtabBar setBackgroundImage:[UIImage imageNamed:#"tabbar.jpg"]];
I know how to add back navigation button with image or change the tile but I haven't seen any example with background image and its title (#"back").
Can I add a custom UIButton with custom background image and title?
This, what I finally did in my code actually works!!!
Just update "forState" and "barMetrics" values for different appearances.
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:#"myImage"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
I'm not sure what you mean by (#back) but here is how I was able to get an image in the back button and the the UINavigationBar:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"myLogo.png"] forBarMetrics:UIBarMetricsDefault];
UIImage *backButton = [[UIImage imageNamed:#"HeaderTest.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
This is an ios 5 solution. Thank you to these sources:
http://www.whypad.com/posts/ios-5-problem-setting-image-for-uinavigationbar/1011/
http://iosdevelopertips.com/user-interface/ios-5-customize-uinavigationbar-and-uibarbuttonitem-with-appearance-api.html
i am using a MPMoviePlayerViewController inside my Project. I have defined the following appearance for UIButtons and UINavigationbar like so:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
setBackgroundImage:[UIImage imageNamed:#"woodenBarButton"]
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navigationbarBackground"]
forBarMetrics:UIBarMetricsDefault];
So now MPMoviePlayerViewController is also using a navigation bar. The problem is now: The button uses the given appearance but the toolbar not => it looks crappy. So now i have the following questions:
Can i convince the UINavigationBar in MPMoviePlayerViewController to use the appearance?
OR can is remove appearance completely only for the MPMoviePlayerViewController.
I tried to access the button via playerViewController.navigationitem.leftbarbuttonitem and overwrite properties but that doesn't work.
Would be great if you can help me. Thanks.
have you tried also setting appearanceWhenContainedIn for MPMoviePlayerViewController? appearance and appearanceWhenContainedIn works both at the same time.
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navigationbarBackground"]
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearanceWhenContainedIn:[MPMoviePlayerViewController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];