How to adjust the font size of the UINavigationBar so that it fits the size of the titleView? - objective-c

I like to use the default size of UINavigationBar.
However, sometimes the title is too long and I want the font size to get reduced appropiately.
How would I do so?
I suppose, first I need to find out the size of the titleView first. I think that can be done.
Then I need to call a function that will tell me the appropriate font size.
Then I would need to specify the font with that size WITHOUT changing the font name for that UINavigationBar.
Anyone knows how to do any of those (doesn't need to be all).

You need to set the titleTextAttributes property of the UINavigationBar. You can get the font size and font type from the same property and adjust or change the font size and font type depending on ur requirement.
Check out the documentation for more details on the same.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html

Related

Objective C multiline UILabel is not working

Here I have attached the scenario of my issue.
Current View
Here Top Title is a bit long string. But my view is shown partially.
Here I added the storyboard properties that I used for my UILabel.
Can someone suggest a solution to make this UiLabel as multilined one ?
You can't have a multi-line label with a fixed font size, if that label is constrained to a certain height.
Either the height needs to scale to allow more lines at that fixed font size, or the font size needs to scale down to fit all the text in.
If neither are possible, then the text will be truncated.
If your label is constrained to a certain height, then you can change the Autoshrink setting from Fixed font size to Minimum font size and specify the smallest size that you will allow the font to shrink to in order to accommodate longer strings.
Try to change the relation of constraint height: Greater than or equal

How do I animate the font size of CCLabelTTF?

I would like to perform an animation on a CCLabelTTF, where the font size is being animated. I do not want to use CCScaleTo because (of course) then the quality is bad. Has anybody got a clue how to do that ?
I´m afraid you can not animate font size on a CCLabelTTF, you can set the maximun font size you want for your label and then use setScale or CCScaleTo. But take notice that CCLabelTTF is slower than CCLabelBMFont, in my opinion is better to render the bitmap font with any program like bmGlyph, and then use CCLabelBMFont, take a look at cocos2d reference.
But anyway you´ll have to scale the label.

How to Know the maximum font size allowed for a given font name?

Is there any way to know the maximum size a font allowed.
I am doing
textInputTextView.font = [UIFont fontWithName:currentFontName size:doubleFontSize];
frame.size = textInputTextView.contentSize;
For different fonts I am getting wrong contentSize when doubleFontSize is more than 70. For some fonts I get wrong contentSize when doubleFontSize variable is only 40.
I am guessing textView.font = doubleSizeFont is too big for those particular fonts. All are ok when font size is small between 10 to 30.
Is there any way to know the maximum size allowed by a particular font?
Details:
I need an image from UITextView. I am using UIGraphicsGetImageFromCurrentImageContext image is producing ok. But I realized image quality is low. So I tried to make the TextView frame and font double.
When I Write in big font "I am a good boy" if good is the right most word. I get "I am a boy" the right most word good disappears I get some blank space on right side of the image. How tragic :)
You Can Calculate height/Width of the content by using the following code.Then resize your frame. Here my Width is fixed (290) and Calculating the height.
CGSize strSize= [DataToBeDisplayed sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:CGSizeMake(290.0,99999.0)];
frame.size.height = strSize.height
I believe the issue that you are having is because you are using an UITextView. Text views inherits from the UIScrollView so it would not decrease the size of your font, it would only adapt its contents size and make your text scrollable.
Use an UITextField instead which also inherits from the UIView (thus can be used as an image) but allows for greater control. Fix its size to the maximum you would like it to be on screen and then working with both the [mylabel adjustsFontSizeToFitWidth:Y/N] and the [mylabel setminimumfontsize:somefontsize] methods, constrain it if too much text is entered. This will yield you a crisp big font and dynamically fit it upon input
~/End of Line

Phantom warning: Unsupported configuration minimum font size is greater than current font size

XCode is giving me a warning about my minimum font size being greater than my current font size. When I click on the warning, it takes me to a XIB file but it only highlights the outer object, none of the inner objects which actually have a font size attribute. Just to be sure, I went through each object and made sure their minimum font size was smaller than their current font size, but Xcode still gives me this warning. What is this warning trying to point to?
I fixed this issue by increasing the font size on a label object, then toggling off auto shrink on it, then rebuilding, then turning auto shrink back on.
There are two scenarios at play, and two solutions accordingly:
1) If you want to auto-shrink your label
Increase the minimum font size of your label to something safe, say 16point
Modify your code to set the font size to your desired font size at run-time
2) If you don't care about auto-shrink: simply change the "Autoshrink" setting to "Fixed Font Size" and this should correct the behavior regardless of what you have your font size set to in Interface Builder
I had the same problem and it was difficult to identify which label was the problem.
Then I opened the storyboard as Source Code and search for minimumFontSize. I compared minimumFontSize with fontDescription's pointSize, to check which value was equal to or greater than the minimumFontSize.
Replace minimum font size with minimum font scale.

Xcode 4 Interface Building Font Not Updating/Showing

When I am changing the font of a label to anything other than the default, the label's font never changes. I can change the font size but not the displaying font. However, when I double click on the label, I can see what the label's font would look like. Can anyone help me with this?
Not all fonts are available on the iPhone. If you are setting the font to an unavailable one, it will default to helvetica. Search the net for a list of the fonts you can use.
You can reference http://iosfonts.com/ for fonts available for each version of iOS. Fonts outside this list will appear as Helvetica, as jrturton said.
I would suggest expanding the size of the text box, by dragging its outermost edges? Despite having made your changes if the selected font/font size combo is to large for the text box to handle it will remain smaller than what you selected even though when you go into the highlight view it appears correct
Edit
Just Because its in that font selection tool does not mean it will show up on the device