gpt4 book ai didi

ios - 如何更改 UISegmentedControl 上文本的字体大小?

转载 作者:可可西里 更新时间:2023-11-01 04:10:26 24 4
gpt4 key购买 nike

以下是初始化我的 UISegmentedControl 的代码。

- (void)initializeToolButtons
{
NSArray *buttonTitles = [NSArray arrayWithObjects:@"ANNEXET", @"HOVET", @"GLOBEN", "ALL", nil];

toolbuttons = [[UISegmentedControl alloc] initWithItems:buttonTitles];
toolbuttons.segmentedControlStyle = UISegmentedControlStyleBar;
toolbuttons.tintColor = [UIColor darkGrayColor];
toolbuttons.backgroundColor = [UIColor blackColor];
toolbuttons.frame = CGRectMake(0, 0, 320, 30);

[toolbuttons addTarget:self action:@selector(toolButtonsAction) forControlEvents:UIControlEventValueChanged];

[self.view addSubview:toolbuttons];
}

如何减小 UISegmentedControl 上每个项目的字体大小?

注意: toolButtons 已在全局声明。

最佳答案

非常简单:

UIFont *Boldfont = [UIFont boldSystemFontOfSize:16.0f];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:Boldfont forKey:UITextAttributeFont];
[segment setTitleTextAttributes:attributes forState:UIControlStateNormal];

关于ios - 如何更改 UISegmentedControl 上文本的字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3493801/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com