Font Issue in iPad - iphone

I am working with custom fonts. it is working fine with iPhone
[btnHourMins.titleLabel setFont:[UIFont fontWithName:#"Rockwell-Bold" size:18]];
[txtPrice setFont:[UIFont fontWithName:#"Rockwell-Bold" size:18]];
but when i used it in iPad then it display strange behavior (see in image), it display only half of the textbox an button.No any type of frame of button or textField set by me.
my coding for ipad is
[txtPrice setFont:[UIFont fontWithName:#"Rockwell-Bold" size:36]];
[lblHourMins.titleLabel setFont:[UIFont fontWithName:#"Rockwell-Bold" size:36]];
and if i set the size 10 instead of 36 it works fine. I download font from heare http://www.freefontsdb.com/detail/8042/Rockwell-Bold How can i solved this Problem. I searched from last 2 days.
1) No any type of view above on UITextField of UIButton
2) NO any type of frame set by me in coding (I just set the font).
3) Size of the Textfield and button is very bigger.
When i set backgroundclour Pink it display ...

Looks like the frame of your label isn't tall enough for the size of the font.
You will need to adjust the height to see the full text, or have it shrink the fontsize based on what will fit in the label.
Edit:
Sorry I didn't see the additional text after your picture. Can you verify that the view is big enough? Try setting the background color to see it's frame.

I Found the solution. its the problem of font file when i tried with this
http://www.2shared.com/file/DEGKglFX/ROCKB.html
It working fine.

Related

iOS 5 UIButton title showing with ellipsis

I have a problem regarding the UIButton title in iOS5. They are clipped and show like in this photo. I don't want them to be clipped, i want to show the full title.
In iOS6, they work perfectly.
Please tell me how can i resolve this?
you simply need to increase the width of your UIButton to show full Title, i have posted sample snippet for better idea, try it. You just need to increase the width of button.
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
[btn1 setFrame:CGRectMake(20, 200, 150, 25)];
[btn1 setTitle:#"This is Long Title" forState:UIControlStateNormal];
[self.view addSubview:btn1];
Guys i have found the solution.
It was pretty simple, you just need to set the button font size in the interface builder to a larger or the same font size than that of the UIapperance font proxy.
I think AutoLayout may be the culprit for this. Check to see if your constraints aren't forcing the label to shrink.
I assume that you are setting your custom font from the code but you are setting the text for the buttons from the IB. So my simple explanation is that as #MichaelScaria said, your custom font is larger. The text is clipping because the size of the label inside the button is adjusted for the current font and size. Since you are changing the font and size after the text is set you need to re-set the title of the button or call 'sizeToFit' on that button.
For those of you here due to ellipsis and use of UIBarButtonItem know that there is a possibleTitles property on UIBarButtonItem with docs that read:
Use this property to provide a hint to the system on how to correctly size the bar button item to be wide enough to accommodate your widest title. Set the value of this property to an NSSet object containing all the titles you intend as possible titles for the bar button item. Use the actual text strings you intend to display.
This property applies to bar button items placed on navigation bars or toolbars.

How to use colorWithPatternImage: with UILabel

I am trying to create a UILabel with customized text that shows the current score of a game. The customer has given me screen shots where they would like the color/pattern of the text to be like that of a wooden panel, so it looks to be brownish with darker swirls within it.
Is this even possible? I have spent an enormous amount of time scouring the web for something related to this and have found nothing concrete. One lead I followed that didn't pan out was using:
[UILabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed: #"WoodenPanel.png"]]];
It seems like there's a way to use an image and set it as the color for the text. But what results when I use this is a completely black UILabel. Is this on the right track? Or is this simply not possible?
You have to do it like this:
[labelName setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"IMAGENAME.PNG"]]];
NOT like you did:
[UILabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"IMAGENAME.PNG"]]];
You have to put the name of the declared label instead of UILabel
Can text in UILabel have a colorWithPatternImage: assigned to it?
It does use the colorWithPatternImage though
What do you mean by it didn't pan out.
Also this is a possible duplicate of the link I just gave you.
It turns out I had actually implemented it correctly. The line of code I provided above was not an exact line out of my program, but more of a generality.
The reason I was getting a completely black font was that part of the particular image I was using was entirely black. It seems that the image isn't scaled down to fit the text and UILabel so what was being revealed was the bottom 1/5 of the image. I did not have to solve this problem as the image provided for me to implement this was a repetitive pattern throughout the image so that any part of the image would produce the desired effect of a wooden panel type color font.

Left-aligned text at viewDidLoad instead of center with custom font

I'm using a custom font on an iPhone app. This font is used on UIButtons and is displaying well.
In IB, I'm setting up horizontal alignement to center and changing the font programaticly with :
[self.playButton.titleLabel setFont:[UIFont fontWithName:#"myfont" size:30]];
when the viewDidLoad is reached.
On the screen, when the view appear, the button's label is first left-aligned in my button and then, 1/2 sec later, it switch to center like I want.
It looks really strange ... if anyone have a clue about this, thanks a lot !
EDIT:
When using
[self.playButton.titleLabel setTextAlignment:UITextAlignmentCenter];
It's nearly the same, the text is cut and then appears totaly.
I am having EXACTLY the same problem. It appears using (sorry for the code, is Xamarin.iOS's C#, not obj-c) UILabel.Appearance.Font = UIFont.FromFile... Removing that let me set font even in the ViewDidLoad!

UILabel text scaling, Programmatically?

I want to change my UILabel text or UILabel itself's size by using UISlider, I know it's something we don't do it for an normal application. But basically I am trying new and different things to explore Objective -C language and iOS platform.
So far I am able to change colour of a font by UISlider, Which looks really great, So thought of changing it's size too by UISlider. Below I am posting pictures to clarify my thoughts visually!
From ----->
To ------->
While making those images I realised I might have to change size of UILable and Size of font too. Am I right? Is this possible?
textLabel.font = [UIFont boldSystemFontOfSize:slider.value];
CGSize newSize = [textLabel.text sizeWithFont:textLabel.font];
This should make it
an alternative is to set the fram of the label above the complete size above the textField and set textAlignement = center
its quite simple actually
According to slider change value dynamically increase height and width of your label..
There can be many ways you can handle this, one way would be to just change the font size with slider and when you change the font calculate the frame size with sizeWithFont: instance method of NSString.

How to type a text in imgeview. Right now sucessfully drawing using mouse

How to type a text in imgeview... right now successfully drawing using mouse. I need to type text in same image view using keyboard...
Try superimposing a UITextView on top of your UIImageView and set appropriate frames for both so that the text appears until where you want it to appear.
Set this property for your UITextView
myTextView.backgroundColor = [UIColor clearColor];
myTextView.textColor = [UIColor redColor]; //or whatever color you like based on the background image in your UIImageView.
Of course you will have to take care of the scrolling when the keyboard comes up after the UITextView becomes active.
If you want more assistance, please elaborate upon your question and your need.