UILabel Text Not Appearing on Some Devices - iphone

I have a simple UILabel setup and was receiving reports from some users that they could not see the information. I did some testing and found that I can see the text on my iPhone 4, but when I test on my old iPhone 3G, the text of the label does not appear. I can see the label (it has a colored background) but there is no text.
I am assuming most of the users have a 3GS or better, but have not nailed it down to exactly who is / is not seeing the error.
Any ideas why this could be happening ?
myLabel is linked up to a UILabel in interface builder.
myLabel.backgroundColor = [UIColor redColor];
myLabel.textColor = [UIColor blueColor];
myLabel.text = #"MY MESSAGE";
myLabel.frame = CGRectMake(0, 100, 320, 40);

I had this problem and tracked it down to a font problem. Helvetica Neue Medium does not appear on my iDevices running iOS 4.2.1. Helvetica Neue Regular is visible on them.

Im assuming that you are using a standard UILabel and not some subclass found on the internet. Are you using a custom font? Are you seeing the red backround? There are many things that could be going wrong, we need some more information.

Related

UILabel font switches back after unselecting text

I have a problem: I want to change the font in my UILabel. When I select the text in the UILabel and I change the font it works, but when I unselect the text, the font comes back to defaut.
Someone have an idea?
Thx
Are you doing it in interface builder? It is very straight forward though. You can also do that using code.
lblName.font= [UIFont fontWithName:#"Arial" size:15];
Something like this.
UIFont *myFont = [ UIFont fontWithName: #"Arial" size: 18.0 ];
textLabel.font = myFont;
This should change the font, however Are you changing it in IB? Also it depends on the type of font you are selecting. It may not be visible in IB and rendering on device depends on the fonts available on it.
labelName.font=[UIFont boldSystemFontOfSize:18]; or any other font style can be assigned as desired.

changing font size of UIButton

I have a UIButton which displays a text, with the following code:
[button setTitle:#"Join this group" forState:UIControlStateNormal];
however, how do I change the font size for this?
I tried
button.titleLabel.font = [UIFont fontWithName:#"Arial-MT" size:8.0];
but I think it's a totally different thing.
Or at least how do I make the text to adjust to the size of the button frame.
Should I just use textLabel.text instead?
The reason that the code you're posting isn't working is probably because Arial isn't present in iOS. You can change the properties of a UIButton's titleLabel just like any other instance of UILabel. Read about that here.
So, you can change the font size with something like:
button.titleLabel.font = [UIFont systemFontOfSize:14.0];
You can choose a font by name, but not all fonts are available on iOS. Here's a list of ones that are.

Create UILabel background similar to selected UITableViewCell

I want to create a UILabel and set its background to the gradient-blue like a selected UITableViewCell. I suspect I need to use UIColor colorWithPatternImage:. If yes, I am not sure what the best way to get the pattern image is. Or, any other suggestions on how to accomplish this?
I would prefer not to create a pre-rendered background image since I need this to work on iPhone 3GS, 4 and iPad which all will require different background images.
The image used by Apple is UITableSelection.png. I have attached the standard and #2x images.
UIView *selectedView = [[UIView alloc] initWithFrame:self.bounds];
selectedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"UITableSelection.png"]];
cell.selectedBackgroundView = selectedView;
Cool post here on customising cell appearance...
http://www.raywenderlich.com/2033/core-graphics-101-lines-rectangles-and-gradients
It's an undocumented color, I'm not sure if you'd want to use an undocumented color. But it's called
[UIColor tableSelectionColor]
Also, it doesn't have the gradient effects that you want. I assume it's a gradient overlay applied to the cell? I don't know how apple does it, but if you wanted to know the color, that's what it is. the RGB values are 0.16, 0.43, 0.83 respectively.
Your_label_name.backgroundColor = [UIColor colorWithRed:72.0/255.0 green:118.0/255.0 blue:255.0/255.0 alpha:1.0];
also refer this link :
http://cloford.com/resources/colours/500col.htm

Which font and size does apple use for the navigation bar title?

I made an totally custom navigation bar and would like to use the exact same font and size like apple does for the title of their navigation bar. It looks like some kind of fat printed arial, but not sure if that's right. Does anyone know?
iOS12 - iOS15 Large Title - System Bold 34 (San Francisco)
[UIFont boldSystemFontOfSize:34]
iOS9 - iOS15 Regular centered title - System Semibold 17 (San Francisco)
[UIFont systemFontOfSize:17 weight:UIFontWeightSemibold]
iOS8 - System Semibold 17 (Helvetica Neue)
[UIFont systemFontOfSize:17 weight:UIFontWeightSemibold]
iOS7 - System Bold 17 (Helvetica Neue)
[UIFont boldSystemFontOfSize:17];
Nice link about typo in iOS
https://learnui.design/blog/ios-font-size-guidelines.html
Definitely not Arial. It's Helvetica. You can probably get the same font using
UIFont *navFont = [UIFont boldSystemFontOfSize:18];
Change the size to find out what Apple is using (and write it below in a comment if you find the best one).
All the navigation bar text has a white shadow underneath it to give it the embossed effect. It's a white shadow 1 pixel underneath the text. Use shadowColor and shadowOffset in a UILabel to get the same effect.
For iOS7 the correct font size is 17pt:
UIFont *navFont = [UIFont boldSystemFontOfSize:17];
UIFont *navFont = [UIFont boldSystemFontOfSize:22];

How to parse and show hyperlinks (phone number/email addresses etc) in UILabel?

Almost everywhere in the iPhone, you can type text and the OS will recognize portion of the text to be hyperlinks (phone numbers, email addresses for example). However I tested this in my own app with a UILabel and it doesn't work. How do I activate this?
Does the iphone sdk provide this functionality out of the box or do I have to do the parsing logic myself (which is a lot of work)?
You could use UITextView as follows:
UITextView *myView = [[UITextView alloc] initWithFrame: frame];
myView.text = #"this is http://google.com link";
myView.editable = NO;
myView.dataDetectorTypes = UIDataDetectorTypeLink;
//cell is the TableView's cell
[cell.contentView addSubview:myView];
[myView release];
Might want to check out Styled Labels under the Three20 project.
Give it a shot with a UIWebView.