How to change text color for tab bar button in storyboard ios8 - ios

I changed tab bar background in Bar Tint field and want to change text colour for tab bar button. By default is grey and blue.
I try to change field Tint in section View, but it doesn't help.

NSDictionary *attribute = #{NSForegroundColorAttributeName:[UIColor redColor]};
[[UITabBarItem appearance] setTitleTextAttributes:attribute forState:UIControlStateNormal];
This will change the text colour for the tab bar button.

This is for selected state:
[[UITabBarItem appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor redColor]} forState:UIControlStateSelected];
This is for not selected state:
[[UITabBarItem appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor greenColor]} forState:UIControlStateNormal];

Try it
To change tabbar text color you can use this
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary [UIColor redColor], UITextAttributeTextColor,[UIColor redColor],UITextAttributeTextShadowColor,[NSValue valueWithUIOffset:UIOffsetMake(0, 0.5)], UITextAttributeTextShadowOffset,[UIFont fontWithName:#"Arial" size:10], UITextAttributeFont,nil]forState:UIControlStateNormal];

Related

How to set a different unselected image and text color on UITabBarItem

I'd like to set different colors for a UITabBarItem's title text and image in the unselected state.
For the selected state, I can accomplish this like so:
[[UITabBar appearance] setTintColor:[UIColor purpleColor]]; // image color
[[UITabBarItem appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName: [UIColor orangeColor] } forState:UIControlStateSelected]; // text color
For the unselected state, I'm attempting the following:
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blueColor]]; // image color
[[UITabBarItem appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName: [UIColor redColor] } forState:UIControlStateNormal]; // text color
But for some reason, the unselectedItemTintColor setting overrides whatever I try and set for the titleTextAttributes – so in the snippet above, both the text and image would appear blue.
I've also tried changing the titleTextAttributes directly on the UITabBarItem after I've created it (instead of using appearance), but again this seems to have no effect.
How can I achieve different unselected colors? Is it possible?
I managed to solve this shortly after posting. It turns out that while setting the unselectedItemTintColor using UIAppearance overrides the titleTextAttributes for the item, everything works correctly if you set the unselectedItemTintColor directly on the tab bar itself.
So instead of
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blueColor]];
just do
[self.myTabBarInstance setUnselectedItemTintColor:[UIColor blueColor]];

Change item color in UITabBar iOS

My app has a Tab Bar like the follow:
The Tab Bar must be green and as you can see the icon of the item in Tab Bar are a little hard to see. How I can change the color of the icon in this Tab Bar? I've to use the standard Tab Bar.
Thank you
try this
[[self tabBar] setSelectedImageTintColor:[UIColor greenColor]];
or this
[UITabBarItem.appearance setTitleTextAttributes:#{
UITextAttributeTextColor : [UIColor greenColor] } forState:UIControlStateNormal];
[UITabBarItem.appearance setTitleTextAttributes:#{
UITextAttributeTextColor : [UIColor purpleColor] } forState:UIControlStateSelected];
Or this
[[self tabBar] setTintColor:[UIColor redColor]];
or this
[UITabBarItem.appearance setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor greenColor]} forState:UIControlStateNormal];
[UITabBarItem.appearance setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor purpleColor]} forState:UIControlStateSelected];
Instead using of icon you can use icon image by using the following code
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
tabBarItem1.selectedImage = [[UIImage imageNamed:#"selectedImage.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
tabBarItem1.image = [[UIImage imageNamed:#"unselectedImage.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
tabBarItem1.imageInsets= UIEdgeInsetsMake(6, 0, -6, 0);
Try this
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];
// set tabbar background image
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"tabbar_bg"]];
// remove shadow image of tabbar
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
I would suggest, to change background of UITabbar to some darker colours, instead of green. Just leave the default gray color(Apple masks to gray) for unselected tab. Use below snipped to set selected tab mask color.
[[UITabBar appearance] setTintColor:[UIColor redColor]];
This will avoid confusion to end users whether a tab is selected or in unselected state.

Change tintColor of unselected UITabBarController item title and background image

How can I change the tintColor of an unselected UITabBarItem title and background image iOS 8?
The default color for an unselected state is a light gray color, but it does not show on my darkish shade UITabBar background
I'd like my unselected state to have a color of [UIColor blackColor]
Inside my app delegate didfinishlaunchingwithoptions: I have
UIImage *deselectedE = [[UIImage imageNamed:#"mincraft_axe_green_32.png"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
UIImage *selectedE = [[UIImage imageNamed:#"mincraft_axe_green_32.png"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
e.tabBarItem = [[UITabBarItem alloc] initWithTitle:#"Profile" image:deselectedE selectedImage:selectedE];
[[UITabBar appearance] setTintColor:[UIColor blackColor]];
Figured it out!
Use this to change the color of the text:
[[UITabBarItem appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName : [UIColor greenColor] }
forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName : [UIColor blackColor] }
forState:UIControlStateSelected];
And make sure that image rendering mode is set to ORIGINAL for the images
UIImage *deselectedImage = [[UIImage imageNamed:#"deselectedImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *selectedImage = [[UIImage imageNamed:#"selectedImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
In your AppDelegate.m inside of application didFinishLaunchingWithOptions: use the following code:
//unselected icon tint color
[[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
//selected tint color
[[UITabBar appearance] setTintColor:[UIColor greenColor]];
//text tint color
[[UITabBarItem appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName : [UIColor whiteColor] }
forState:UIControlStateNormal];
//background tint color
[[UITabBar appearance] setBarTintColor:[UIColor blueColor]];
You can also render the image as original from the attributes inspector for the asset file without writing any code
You can also set it up directly in Storyboard... Check my answer here:
How to set UITabBarItem's unselected tint, ***including system items*** (iOS7)
If you're using Storyboard you can also set both Image for Bar Item and Selected Image for Selected Bar Item to get unaltered image in tabBar.
Alternatively in Assets catalog, you can select Render As: Original Image in the attributes of your image (View > Utilities > Show Attributes Inspector or shortcut ⌥⌘4 (Option + Command + 4))

How to change these colors on Navbar?

I have succesfully change the navbar button with this:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:26.0/255 green:132.0/255 blue:182.0/255 alpha:.5]];
What about if I want to change the color of the title (from black) or the color of the button?
This is what I have in my App Delegate in a method specially for changing appearances.
// set button tint colour to white
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
// set the bar tint colour to purplish
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:.2 green:.458823529 blue:.592156863 alpha:1.0]];
// set title text label colour to white
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
For navigation bar title color in iOS7 you should use the setTitleTextAttributes of UINavigationBar appearance
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,shadow, NSShadowAttributeName, [UIFont fontWithName:#"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]];
For more navbar customization refer http://www.appcoda.com/customize-navigation-status-bar-ios-7/

xcode - Design / Redesign MailController / MFMailComposeViewController

Is it possible to Redesign the MFMailComposeViewController?
How?
The App Dropbox can do it.
Picture: http://jonathangurebo.tumblr.com/post/40436277822
Can I change the "MessageUI.framework"?
To answer your request regarding customizing the appearance of ALL navigation bars in the app, use this in your application:didFinishLaunchingWithOptions: in your app delegate:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"image"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTintColor:[UIColor blueColor]];
[[UINavigationBar appearance] setAlpha:1];
//change background image and tint color for navigation buttons
// Set the text appearance for navbar
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:2 forBarMetrics:UIBarMetricsDefault]; //change vertical appearance of navigation bar title
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(1, 1)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:#"HelveticaNeue" size:22], UITextAttributeFont,
nil]]; //set custom font info

Resources