iphone - 设置标签字体

发布于 2024-10-08 15:27:44 字数 189 浏览 0 评论 0原文

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

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

我的代码正确吗?

How can I set the font of button label to Century Gothic Bold of size 46.
I'm using following code:

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

Is my code correct or not?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橘寄 2024-10-15 15:27:45
 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];
 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];
ヤ经典坏疍 2024-10-15 15:27:45

我认为 iOS 不支持你的字体。但有一种字体叫AppleGothic。

请参阅此链接

http://www.prePressure.com/fonts/basics/ios- 4种字体

I think iOS doesnt support your font. But there is a font called AppleGothic.

see this link

http://www.prepressure.com/fonts/basics/ios-4-fonts

凝望流年 2024-10-15 15:27:45

我昨天用过这个:

onlineButton.titleLabel.font = [UIFont boldSystemFontOfSize:onlineButton.titleLabel.font.pointSize+3];

所以试试这个:

yourButton.titleLabel.font = [UIFont fontWithName:fontName size:size];

I used yesterday this:

onlineButton.titleLabel.font = [UIFont boldSystemFontOfSize:onlineButton.titleLabel.font.pointSize+3];

So try this:

yourButton.titleLabel.font = [UIFont fontWithName:fontName size:size];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文