Customize the tabbar and tabbar item - iphone

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.

Related

Custom UITabBar Background image

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;

change navigationbar on only one view

I have set a custom navigationbar in my appdelegate. You can see the code over here.
UIImage *image = [UIImage imageNamed:#"navbar.png"];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
But now I'm working with the eventkit framework. What I want is when I go to eventdetails, that I get the standard navbar layout.So without the image.
EKEventViewController *vc = [[EKEventViewController alloc] init];
[vc.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
vc.event = [dataSource eventAtIndexPath:indexPath];
vc.allowsEditing = YES;
[calendar.navigationController pushViewController:vc animated:YES];
I've tried the following but it is not working.
Any help?
you can do one thing, take the screenshot of one viewController with default navigation bar , just crop only navigation bar area i.e. make image of 320 x 44 size.
when you want again your by default navigation bar , that time use this cropped image as background of navigation bar ,add following code
UIImage *image = [UIImage imageNamed:#"defaultNavbar.png"];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
again when you navigate to another viewController having custom Navimage then again draw nav image by help of your custom image code i.e.
UIImage *image = [UIImage imageNamed:#"navbar.png"];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];

Navigation bar image black

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.

How to add image to UITabBarController

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"]];

back navigationItem with title & background image

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