See following code carefully. Because it works perfectly. Try to add in your application. it will work
- (void)viewDidLoad {
[super viewDidLoad];
// title label - tip
UILabel *tmp=[[UILabel alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];
tmp.textColor=[UIColor colorWithRed:(14.0/255.0) green:(105.0/255) blue:(128.0/255) alpha:1.0];
[tmp setFont:[UIFont fontWithName:#"Arial" size:18]]; tmp.text=#"sagar";
tmp.backgroundColor=[UIColor clearColor]; [self.view addSubview:tmp]; [tmp release];
}
Now, see following code carefully. Because it doesn't work. See there is nothing difference between both of these code.
- (void)viewDidLoad {
[super viewDidLoad];
// title label - tip
UILabel *tmp=[[UILabel alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];
tmp.textColor=[UIColor colorWithRed:(14.0/255.0) green:(105.0/255) blue:(128.0/255) alpha:1.0];
[tmp setFont:[UIFont fontWithName:#"Arial Black" size:18]]; tmp.text=#"sagar";
tmp.backgroundColor=[UIColor clearColor]; [self.view addSubview:tmp]; [tmp release];
}
I have just mentioned #Arial Black# instead #Arial# .
However it isn't working.
Is it because of iPhone doesn't support =Arial Black= ?
I would like to know why it isn't working.
How many different kind of font does iPhone support?
Is there any list?
How to set a font name to a UILabel or to any control ? (font which has space within there name )
Thanks in advance for sharing your knowledge with me.
Here is a list of fonts available in the iPhone OS. It would seem Arial Black is not among them.
Try #"Arial-BoldMT"
Besides, you could always make yourself a list of available fonts:
for( NSString *familyName in [UIFont familyNames] ) {
for( NSString *fontName in [UIFont fontNamesForFamilyName:familyName] ) {
NSLog(#"%#", fontName);
}
}
There are plenty of font apps in the App Store to see all the fonts - one of which is iFonts, an app I developed so I could email the list of fonts to someone else on the team.
Related
What me actually doing:-
lbl1= [[UILabel alloc] init];
lbl1.frame=CGRectMake(10, 10,90, 40);
lbl1.textColor=[UIColor blackColor];
lbl1.text=#"Definitions";
lbl1.font = [UIFont boldSystemFontOfSize:16.0f];
UILabel* finalLabel=[[UILabel alloc] init];
finalLabel.frame=CGRectMake(100, 10,90, 40);
finalLabel.text=[NSString stringWithFormat:#"%#:,The following terms shall have the described meaning:",lbl1];
finalLabel.font = [UIFont fontWithName:#"Helvetica" size:14];
finalLabel.numberOfLines=2;
[self.view addSubview:lbl1];
[self.view addSubview:finalLabel];
Didn't get the proper result of final label
it print:- Definitions
UILABEL:0X68640;frame(10,10,90,40);text='Definition',CliptoBound=YES;Userintraction......
You mean partially bold in a single UILabel. right?
You should check this ONE
Check out with below urls:
Custom Label 1
Custom Label 2
It will be helpful to you and your functionality can be achieved.
Cheers!
I am trying to use a custom font in my application, which is of ttf format. In the Project settings, I have addd that font name like below .
And I have added that font in my resources folder like below
And the font Which I am trying to use is this one
_enterButton.titleLabel.font = [UIFont fontWithName:#"Venus Rising" size:45.0];
If I use Arial or some other font, it works fine. But when I am trying to use this font, it is not at all working. Can anyone tell me why ??
I downloaded the font and as I thought it has different name than what is the name of the file. Look at this image.
Also don't forget on adding the name to the Info.plist of your app, under the key "Fonts provided by application". Hope it helps! :)
You missed extension of font in info.plist, I mean in Info.plist, "Fonts provided by application" you need to set "Venus Rising.ttf" then your problem will be solved
I encountered the same problem few days ago. For me the the font name was different from the ttf file name.
Try this loop to check all the font available in your app :
for (id familyName in [UIFont familyNames]) {
NSLog(#"family name : %#",familyName);
for (id font in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(#" %#",font);
}
}
In your case, Venus Rising should appear as a family name but the exact name of the font you should use in your code may be VenusRisingRegular or something like that.
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 240, 40)];
[label1 setFont: [UIFont fontWithName: #"Grinched" size:24]];
[label1 setText:#"Grinched Font"];
[[self view] addSubview:label1];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 240, 40)];
[label2 setFont: [UIFont fontWithName: #"Energon" size:18]];
[label2 setText:#"Energon Font"];
[[self view] addSubview:label2];
Please try this.
It's may help to you
I have to display coptic font on one of my apps. I did a research and found that it is not supported on iOS. This is the website I referred to.. http://iosfonts.com/
Is there a way I could show it on UIWebView or UITextView?
Looking forward for some solutions..
Providing custom font file that can display the coptic font.
Add the font file (xxx.ttf) into your project.
Add "Fonts provided by application" in info.plist. Add the font file name(xxx.ttf) you needed into that array.
Use it as [UIFont fontWithName:fontName size:size];
This fontName is not the filename (eg. xxx.ttf, not xxx for this case), you should open your ttf file and see the name of it.
following code is use when the inserting the after installing the font into the project.
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 240, 40)];
[label1 setFont: [UIFont fontWithName: #"Grinched" size:24]];
[label1 setText:#"Grinched Font"];
[[self view] addSubview:label1];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 240, 40)];
[label2 setFont: [UIFont fontWithName: #"Energon" size:18]];
[label2 setText:#"Energon Font"];
[[self view] addSubview:label2];
And more detail and tutorial regarding the custom font then goto Reference link here.
In my Application i am using Custom font. i copied my font.ttf file in my project directory and i used following code to set custom font to a label.
[input setFont:[UIFont fontWithName: #"My Font" size: input.font.pointSize]]
The problem is it works perfect in iPhone 4.2 simulator but it in iPad 4.2 simulator it just Displays Default Font. How to resolve this?
Following code is use for the custom font.
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 240, 40)];
[label1 setFont: [UIFont fontWithName: #"Grinched" size:24]];
[label1 setText:#"Grinched Font"];
[[self view] addSubview:label1];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 240, 40)];
[label2 setFont: [UIFont fontWithName: #"Energon" size:18]];
[label2 setText:#"Energon Font"];
[[self view] addSubview:label2];
If you want shows the tutorial for that you visits the refrence link here
May this code help for development.
Happy codeing
Thanks and Regards
#samuel
If You Want To Use Custom-Font..Folow This Steps...
Add the font files to your resource files
Edit your Info.plist: Add a new entry with the key Fonts provided by application.
For each of your files, add the file name to this array
On the example below, I've added the font "DejaVu Sans Mono":
In your application you can the use
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 240, 50)];
[label1 setFont: [UIFont fontWithName: #"DejaVuSansMono-Bold" size:14.f]];
Or if you want to use it in html/css, just use font-family:DejaVu Sans Mono;
Note: this is available in iOS 3.2 and later.
I'm trying to replicate an iphone style navbar in my mac app. But I just can't figure out what font (name and size) that the title in the navbar should be. Does anybody know what it is or have a way to figure it out? Thanks in advance.
Update: Here's a picture. I'm referring to the "Navigation bar" pointed out on top.
http://www.funkyspacemonkey.com/wp-content/uploads/2010/01/iPhone_UI_elements_sizes.jpg
Oh, I just figured it out! Helvetica Neue, as Ben pointed out, and then I used size 20. But then, to complete the look, you need to give it an embossed look. I did this by using this code:
[[myTextField cell] setBackgroundStyle:NSBackgroundStyleLowered];
I found that here: http://whomwah.com/2009/03/11/replicating-apples-embossed-text-in-a-cocoa-app/
Now it looks right.
Prior to iPhone 4, the font is Helvetica. The iPhone 4 uses Helvetica Neue.
The point-size you want will depend on what you mean by 'navbar'.
Replicate title label manually:
UINavigationItem(Category)
- (void)setTitle:(NSString *)title
{
UIFont* font = [UIFont fontWithName:#"HelveticaNeue-Bold" size:20.0f];
CGSize textSize = [title sizeWithFont:font];
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
label.textColor =[UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
label.text = title;
label.font = font;
label.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5f];
label.shadowOffset = CGSizeMake(0,-1);
label.textAlignment = UITextAlignmentCenter;
[self setTitleView:label];
[label release];
}