我的应用程序中有以下代码.
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"?
请仔细查看以下代码.因为它完美无缺.尝试添加您的应用程序.它会工作
- (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];
}
Run Code Online (Sandbox Code Playgroud)
现在,请仔细查看以下代码.因为它不起作用.看看这两个代码之间没有任何区别.
- (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];
}
Run Code Online (Sandbox Code Playgroud)
我刚刚提到#Arial Black#而不是#Arial#.
我想知道它为什么不起作用.
iPhone支持多少种不同的字体? …