【问题标题】:setting UIButton font设置 UIButton 字体
【发布时间】:2012-07-11 23:56:48
【问题描述】:

我有以下代码用于在 UIButton 中设置文本

[self.fullListButton_ setTitle:[NSString stringWithFormat:@"%d", [self.newsfeedItem_.newsfeedToSubjects count] - 3] forState:UIControlStateNormal];

问题是我似乎无法为此设置字体。我该怎么做?

【问题讨论】:

    标签: iphone objective-c ios ipad


    【解决方案1】:

    在较新版本的 iOS 中:

    UIButton * myButton;
    myButton.titleLabel.font = [UIFont systemFontOfSize: 12];
    

    或任何其他字体机制。

    在这里查看 UIButton 部分:

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html#//apple_ref/occ/instp/UIButton/titleLabel

    这里是 UIFont 的东西:

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UIFont_Class/Reference/Reference.html

    在您的代码中:

    self.fullListButton_.titleLabel.font = [UIFont systemFontOfSize: 12];
    

    self.fullListButton_.titleLabel.font = [UIFont fontWithName:@"Arial" size:12];
    

    【讨论】:

    • @xonegirlz :确保您没有尝试为 SystemButton 设置字体。
    • 应该是“titleLabel”,而不是“titleLable”
    猜你喜欢
    • 2020-05-21
    • 2015-02-08
    • 1970-01-01
    • 1970-01-01
    • 2014-01-27
    • 2017-09-15
    • 2019-04-04
    • 2011-10-01
    • 2015-07-03
    相关资源
    最近更新 更多