How can I change a textview font and font size..
I've tried this but it doesnt seem to change anything...
typingText.font = [UIFont fontWithName:#"Marker Felt Thin" size:64.0f];
Thanks!
The actual name of the font is "MarkerFelt-Thin".
typingText.font = [UIFont fontWithName:#"MarkerFelt-Thin" size:64.0f];
Related
I am trying to display some text in a UITextView (no editable) and I am having some problems to change font size, color...
I am using xcode 5 with ios6 appearance. I tried to change parameters in nib file: arribute inspector> text view.
But all I try, seems to do nothing. Nothing changes, I see the text equal as if I didn't modify anything.
I don't write text inside uitextview, I just show it from a variable.
I had the same problems and had already an answer here
You need to set the text of your UITextView and after you can set the font and the color :
_myTextView.text = #"text";
[_myTextView setFont:[UIFont fontWithName:#"Helvetica Neue" size:18.0f]];
_myTextView.textColor = [UIColor whiteColor];
I had a similar problem before. It got fixed when I did the customization after selecting the entire default text.
Here is a sample screenshot :
Hope this helps !
While using Interface builder & iOS7 UIFontTextStyleHeadline
I set my headline label to UIFontTextStyleHeadline
(I guess it can be done also with the following code:)
myHeadlineTextLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
Q:
this works well, yet I would like to have the same functionality only using HelveticaNeue-Thin
just as an example:
titleCustomLabel.font = [UIFont fontWithName:#"HelveticaNeue-Thin" size:(**Dynamic font size as the user defined in his setting**)];
what would be an elegant way to do so?
UIFont has the fontSize property. You can make use of that.
titleCustomLabel.font = [UIFont fontWithName:#"HelveticaNeue-Thin" size:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline].pointSize];
(don't use fontSize at the end)
What I want to do is change the font size.
I know below statement will change the font size, but it changes the font name because we are using systemFontOfSize
[UIFont systemFontOfSize: 13.0];
I know alternate option is as mentioned below.
[myLabel setFont:[UIFont fontWithName:#"Helvetica-Bold" size:13.0]];
but I don't want to use fontWithName as I am setting that in IB.
I don't want to play with font name as my app is multi-language and hence I don't want to play with font name.
Any idea how can I just change fontsize and don't change the fontname.
Too bad that the font metrics properties of UIFont are readonly. It'd be nice if they could be adjusted dynamically without having to do this below:
UIFont * fontFromLabel = myLabel.font;
// now we have the font from the label, let's make a new font
// with the same font name but a different size
if(fontFromLabel)
{
// 13, or whatever size you want
UIFont * newFontForLabel = [UIFont fontWithName: fontFromLabel.fontName size: 13.0f];
if(newFontForLabel)
{
[myLabel setFont: newFontForLabel];
}
}
I'm having an issue where I allow the user to select a font for a label in my project, but then when the user sets the size of that label (using a different button), the label resets to a default font. I'd like to be able to retain the font that the user had applied while still allowing the user to change the font size. Any help is appreciated, thanks!
Here's my code..
-(IBAction)setFont{
[userText setFont:[UIFont fontWithName:#"Arial-BoldMT" size:50.0]];
//I had to add a size when setting the font or else I got an error
}
-(IBAction)setFontSize{
[userText setFont:[UIFont systemFontOfSize:24]];
}
Just use the fontWithSize: method on the label's current font:
- (IBAction)setFontSize {
// Keep the same font but change its size to 24 points.
UIFont *font = userText.font;
userText.font = [font fontWithSize:24];
}
The function [UIFont systemFontOfSize:] will always return default system font. You can just make use of the same function that you call in setFont which is [UIFont fontWithName:size:].
In a UITextView is it possible to set the fontname and then set it to bold?
I know that font name and size can be set using
fontWithName:(NSString *)fontName size:(CGFloat)fontSize
But once this is done how can i make it bold?
The system font on the iPhone is a good choice for many purposes. You can easily select it in a regular, bold or italic style using built-in font class methods. For example
UIFont *mainTitleFont = [UIFont boldSystemFontOfSize:14.0];
UIFont *subTitleFont = [UIFont SystemFontOfSize:14.0];
UIFont *textFont = [UIFont italicSystemFontOfSize:12.0];
But what if you want a font using both bold and italic at the same time, or a different typeface altogether? In that case, you can use the “fontWithName” method as follows.
UIFont *altFont = [UIFont fontWithName:#"Courier-Bold" size:14.0];
Reference
Use the Bold variant of the font, e.g. #"Helvetica-Bold" as the fontName. If using the default system font is ok for you, you can also use boldSystemFontOfSize: method instead.
UIFont *f = [UIFont fontWithName:#"Verdana-Bold" size:12];
yourTextView.font = f;
If you want to give font with name then you can refer below link. It have all font which are provided by iOS with their font names.
iOS Fonts
Thanks.