gpt4 book ai didi

ios - UISegmentedControl 和本地化字符串

转载 作者:搜寻专家 更新时间:2023-10-30 20:16:12 25 4
gpt4 key购买 nike

我有一个包含 3 个段的 UISegmentedControl。英文字符串非常适合,但西类牙字符串稍长,不合适。

enter image description here

enter image description here

为字符串动态调整字体大小以适合段大小的正确程序是什么? UILabel 是否有类似于 minimumFontScale 属性的内容?

最佳答案

试试这个您不需要设置任何最小字体大小。如果需要,它会自动更改字体大小以显示标题。

NSArray *itemArray = [NSArray arrayWithObjects: @"Title1 testing font size", @"Title2", @"Titl3",nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.frame = YOUR_FRAME;
[segmentedControl addTarget:self action:@selector(segmentControlClicked:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:segmentedControl];
for (id segment in [segmentedControl subviews])
{
for (id label in [segment subviews])
{
if ([label isKindOfClass:[UILabel class]])
[label setAdjustsFontSizeToFitWidth:YES];

}
}

关于ios - UISegmentedControl 和本地化字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30028242/

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