I'm trying to change the font for my uitableviewcells,
I'm trying to use this at the moment with not success:
cell.textLabel.font = [UIFont .preferredFontForTextStyle("Avenir")];
Now i've read a lot on this and it seems I should use this instead :
cell.textLabel.font = [UIFont fontWithName: "Avenir" size:22];
Problem is fontWithName does not seem to exist in iOS 8
any ideas??
thanks
The thing is that this is not Swift (it is a kind of horrifying bastardization of Objective-C):
cell.textLabel.font = [UIFont fontWithName: "Avenir" size:22];
This would be Swift:
cell.textLabel.font = UIFont(name:"Avenir", size:22)
Try the following casting way:
cell.textLabel.font = UIFont(name: "Avenir", size:22);
Related
I am attempting to configure cells in a TableView. One of the things I am trying to do is change the font and color of the text in the cells. Here is the code:
- (void)configureView {
UIFont *cellFont = [UIFont fontWithName:#"Raleway-Thin" size:14];
NSDictionary *cellAttributesDictionary = [NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: cellFont];
}
At the colon after NSFontAttributeName I am getting the error Expected ']'. What is causing this error?
The proper syntax for a dictionary literal in Objective-C is #{...};
NSDictionary *cellAttributesDictionary = #{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: cellFont};
how to change font size of label without changing font family in xcode6 ?I am using following line of code:
lblMain.font = [UIFont systemFontOfSize:22];
Here's an example:
lblMain.font = [UIFont fontWithName:#"HelveticaNeue" size:22];
Or - you can even use the current font:
lblMain.font = [lblMain.font fontWithSize:22];
NSString *fontName = lblMain.font.fontName;
CGFloat fontSize = lblMain.font.pointSize;
[lblMain setFont:[UIFont fontWithName:fontName size:NEWSIZE]];
Use following code, if you just want to change font size keeping the same font family:
lblMain.font = [UIFont fontWithName:lblMain.font.fontName size:22.0f];
OR
You can also use this code:
lblMain.font = [lblMain.font fontWithSize:22.0f];
[lblMain setFont:[UIFont fontWithName:#"HelveticaNeue" size:17]];
I have the following code:
UILabel *registerLabel = [ [UILabel alloc ] initWithFrame:CGRectMake(20.0, 90.0, [self screenWidth], 43.0) ];
registerLabel.textAlignment = NSTextAlignmentLeft;
registerLabel.textColor = [UIColor whiteColor];
registerLabel.backgroundColor = [UIColor blackColor];
registerLabel.font = [UIFont fontWithName:#"Helvetica Neue" size:(20.0)];
//registerLabel.adjustsFontSizeToFitWidth = YES;
registerLabel.text = #"Register";
But I see in some of the ios 7 demo apps (like calendar) the font is large but much thinner. I tried using Helevetica Neue Light but that doesn't work. Is there a way to make the font thinner or what font are they using?
I found the answer to be this:
registerLabel.font = [UIFont fontWithName:#"HelveticaNeue-Light" size:(36.0)];
.font is what you need
i have problem. I have dynamic tableview. So i need change text size in my textLabel.
I tried:
one:
cell.textLabel.font = [UIFont systemFontOfSize:30.0f];
two:
cell.textLabel.font = [UIFont boldSystemFontOfSize:12.0];
three:
UIFont *myFont = [ UIFont fontWithName: #"Arial" size: 30.0 ];
cell.textLabel.font = myFont;
But my textlabel not changing. So detailtextlabel - change perfectly but text label - no. What i do wrong? thanks
You can try with the following..
but make sure you write this code before u setting your text
cell.textLabel.text=#"Your TEXT Goes Here";
UIFont *myFont = [ UIFont fontWithName: #"Arial" size: 18.0 ];
cell.textLabel.font = myFont;
hope it helps.
I have an iPad app that creates a pdf and works fine however I am trying to get the headings bold.
Currently I have:
UIFont *font = [UIFont fontwithname:#"arial" size 12];
I would like to know what I need to add to make the text bold as well.
Many thanks
This does the trick:
UIFont *font = [UIFont fontWithName:#"Arial-BoldMT" size:12.0];