How to increase the size of UITabBarItem in iphone? - iphone

I want to increase the Text size of UITabBarItem in my application.It is not visible clearly with its default color and size.
I tried this code but give me error -->UITabBar for instant message does not declare method with selector 'setTitleTextAttributes'.
Does any know how to do it?
[yourTabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[NSValue valueWithUIOffset:UIOffsetMake(0,0)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:#"Helvetica" size:18.0], UITextAttributeFont, nil]
forState:UIControlStateNormal];

I think the default size is fully conveninet for the user. Anyway you want, maybe you should make your own <Tabbar> with UIView, UIButtons and UITabbar-style images.

setTitleTextAttributes:forState: is only available in iOS 5.0 or later. Please refer to UIBarItem Class Reference (UITabBarItem is subclass of UIBarItem). For prior versions of iOS, I think you'd better create your own customized tab bar.
And you may also want to try other methods from the answers in Changing font size of tabbaritem.

For that you should create dynamic tab bar using UITabbar class.
.Using this You can allow own size text ,image,color.

Related

Custom UINavigationBar Font not displaying

My custom TrueType font file that I brought into Xcode is not displaying correctly in the UINavigationBar. Instead of displaying the custom font, it displays the System font (Helvetica Bold).
RootViewController.m
self.title = #"Library";
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIFont fontWithName:#"adellebasic_bold.ttf" size:20.0], UITextAttributeFont,nil]];
I have also made sure that I copied it into Xcode correctly and I declared it under UIAppFonts in the Info.plist file. Also note that the code works if I set it to a UIFont that is included in the iPhone SDK but not a custom font brought in.
Does anyone have the slightest idea for what I'm doing wrong here?
Try this:
NSMutableDictionary *titleBarAttributes = [NSMutableDictionary dictionaryWithDictionary: [[UINavigationBar appearance] titleTextAttributes]];
[titleBarAttributes setValue:[UIFont fontWithName:#"adellebasic_bold" size:25.0f] forKey:UITextAttributeFont];
[self.navigationController.navigationBar setTitleTextAttributes:titleBarAttributes];
[self.navigationController.navigationBar setTitleVerticalPositionAdjustment:4.0f forBarMetrics:UIBarMetricsDefault];
Hope this helps.
actually the font file name and the font name are two different things.
Check This: iOS: How can i set a non system font family, style, size of UILabel? .
Try this name "Adelle Basic Bold".

Change UINavigationBar Font SIze for Select Views

I know how to change the UINavigationBar's title font properties by using this code:
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont boldSystemFontOfSize:16.0f], UITextAttributeFont, nil]];
However, I am finding that when I change the font size in this way it effects all views, not just the view in which I am implementing the above code. The problem is, I want to change the size for just 2 views that have long titles. The other views (including the root view) I wish to retain the default setting for font size. I've tried changing the font size back to normal in the viewDidLoad method using the above code, but it does not work.
Is there a way to change the title font size for just certain views? Thanks.
You should call that code in each view controller's viewWillAppear: method. When you set it in viewDidLoad, the setting gets overridden by the next view controller's actions. You might also have to call setNeedsDisplay on the navigationBar to refresh it (although I don't believe so).
Like so:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont boldSystemFontOfSize:16.0f],
UITextAttributeFont,
nil]];
}

UIBarButtonItem appearance setTitleTextAttributes does not affects UIControlStateDisabled state

Our designer asked me to use specific color for text of disabled UIBarButtonItems. That code I've used to implement this:
NSDictionary* textAttributes = [NSDictionary dictionaryWithObject: [UIColor blueColor]
forKey: UITextAttributeTextColor];
[[UIBarButtonItem appearance] setTitleTextAttributes: textAttributes
forState: UIControlStateDisabled];
But it doesn't changed text attributes.
I've tried this code with Normal state, tried to chage background for UIControlStateDisabled buttons with setBackgroundImage and all thouse experiments works perfectly. But this single combination: setTitleTextAttributes and UIControlStateDisabled doesn't do anything.
Google didn't give me any relevant answer about that specific combination.
Does anybody know other way to change color of disabled UIBarButtonItem or way to make setTitleTextAttributes work for diabled items?
You have to set it for both control state Normal and Disabled.
(2015-11-18 -- As of iOS 9.1 you must still set both.)
It's working fine for me with iOS 5.1. Perhaps it was a 5.0 bug.

Colours within a NSArray arrayWithObjects

I have a simple leader boards table for an iphone game that allows me to view the previous high scores however the background is black and therefore it is not visible. I am using the code:
[highscores addObject:[NSArray arrayWithObjects:#"Title",[NSNumber numberWithInt:5000],nil]];
Can I change the colour easily?
All help greatly appreciated, I expect it is simple but google is coming back with little.
Thanks in advanced!
changing the color is not related with an Array.Its related with the container who displays the Title .
you may binding the Title string to any UILabel.
So you have to set the textColor property to white.
Eg: label1.textColor = [UIColor whiteColor];
To make the UILabel white, remove this code:
[label1 setRGB:0 :0 :0];
And add do this instead:
[label1 setTextColor:[UIColor whiteColor]];
Let me know if this helps you. Posting your code definitely helps. You are doing great at age 14, so keep it up.

How can i change the text color in a UISegmented Control in iPhone app?

The only solution that i can think of so far is by adding images.. but i want the right solution...so i there any way to change the text/title color???
use this method, it is in ios 5.x
UIFont *Boldfont = [UIFont systemFontOfSize:13.0f];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:Boldfont,UITextAttributeFont,[UIColor darkTextColor],UITextAttributeTextColor,nil];
[self.mSegmentControl setTitleTextAttributes:attributes
forState:UIControlStateNormal];
http://www.framewreck.net/2010/07/custom-tintcolor-for-each-segment-of.html
On this post there is the implementation of a category that does what you are looking for.
From iOS SDK, there is no method to do this directly.