我的应用程序中有以下代码.
tmp=[[UILabel alloc] initWithFrame:label1Frame];
tmp.tag=1;
tmp.textColor=[UIColor blackColor];
[tmp setFont:[UIFont fontWithName:@"American Typewriter" size:18]];
tmp.backgroundColor=[UIColor clearColor];
[cell.contentView addSubview:tmp];
[tmp release];
Run Code Online (Sandbox Code Playgroud)
现在,我需要知道,
======>如何通过代码设置"Typeface = bold"?
dev*_*ley 36
您将需要使用该系列中的bold
字体名称.要查看是否有bold
美国打字机版本,请尝试输出
[UIFont fontNamesForFamilyName:@"AmericanTypewriter"]
Run Code Online (Sandbox Code Playgroud)
到控制台.
在这种情况下,你应该使用"AmericanTypewriter-Bold"
.
[UIFont fontNamesForFamilyName:@"AmericanTypewriter-Bold"]
Run Code Online (Sandbox Code Playgroud)
dcr*_*tar 20
那么使用setter属性呢:
// Create a string
NSString *text = @"You are getting sleepy.";
// Get a font to draw it in
UIFont *font = [UIFont boldSystemFontOfSize:28];
// Draw the string
[text drawInRect:(CGRect)
withFont:font];
Run Code Online (Sandbox Code Playgroud)
Naz*_*zir 17
只是NSLog你想要的字体:
NSLog(@" %@", [UIFont fontNamesForFamilyName:@"American Typewriter"]);
Run Code Online (Sandbox Code Playgroud)
你得到了阵列:
(
"AmericanTypewriter-CondensedLight",
"AmericanTypewriter-Light",
"AmericanTypewriter-Bold",
AmericanTypewriter,
"AmericanTypewriter-CondensedBold",
"AmericanTypewriter-Condensed"
)
Run Code Online (Sandbox Code Playgroud)
在Code中使用您需要的任何内容:
UILabel * loading = [[UILabel alloc] initWithFrame:CGRectMake(350, 402, 150, 25)];
[loading setFont:[UIFont fontWithName:@"AmericanTypewriter-Bold" size:12.0]];
[loading setTextColor:[UIColor whiteColor]];
[loading setBackgroundColor:[UIColor clearColor]];
[loading setText:@"Loading ..."];
[self.view addSubview:loading];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
79995 次 |
最近记录: |