How do you set the font size on a UIBarButtonItem?

前端 未结 5 1937
旧巷少年郎
旧巷少年郎 2021-02-03 19:42

I can\'t find a way to set the font size of the title in a custom UIBarButtonItem. The only way I can think of getting around this is to set it as an image which I would like to

5条回答
  •  太阳男子
    2021-02-03 20:05

    [[UIBarButtonItem appearance]setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                         [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
                                                         [UIFont fontWithName:@"FONT-NAME" size:21.0], NSFontAttributeName, nil]
                                               forState:UIControlStateNormal];
    

提交回复
热议问题