iphone - 设置标签字体

标签 iphone uibutton label

如何将按钮标签的字体设置为 46 号的 Century Gothic Bold。 我正在使用以下代码:

        [self.titleLabel setFont:[UIFont fontWithName:@"Century Gothic-Bold" size:46]];

我的代码正确吗?

最佳答案

 UIButton *NameBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    NameBtn=[[UIButton alloc]init];
    [NameBtn setBackgroundColor:[UIColor clearColor]];
    [NameBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    NSString *textb=[[self.searchList objectAtIndex:indexPath.row] objectForKey:@"name"];
    CGSize constraintb = CGSizeMake(310 ,10);
    CGSize sizeb = [textb sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:constraintb lineBreakMode:UILineBreakModeWordWrap];
    [NameBtn setTitle:textb forState:UIControlStateNormal];
    NameBtn.font = [UIFont fontWithName:@"Helvetica-Bold" size: 12.0];
    NameBtn.frame = CGRectMake(85, 12, MAX(sizeb.width ,3.0f),12);
    [NameBtn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    NameBtn.tag=indexPath.row;

    [self.view addSubview:NameBtn];

关于iphone - 设置标签字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4481592/

相关文章:

iphone - 调用 popViewController 动画两次

iphone - 为 UITableViewCell 的飞行设置动画

ios - swift : One Navigation bar item

.net - 如何以编程方式将标签控件添加到 Web 表单中?

java - NumberAxis 标签名称(不是刻度标签)大小和字体

iphone - UIScrollView 没有响应

iphone - 为什么这个动画移动得比它开始的地方低?

iphone - ViewDidLoad 什么是 false

ios - 自定义UIButton时不同状态的IBInpectable属性

linux - 找到两个 clearcase 标签之间的区别(也需要新创建的元素)