UISegmentedControl和本地化字符串

时间:2015-05-04 10:48:45

标签: ios objective-c localization uisegmentedcontrol

我有一个带有3个段的UISegmentedControl。英文字符串非常合适,但西班牙语字符串稍微长一些,而不是。

enter image description here

enter image description here

动态操作字体大小以使字符串适合段大小的正确步骤是什么?是否有类似于minimumFontScale的{​​{1}}属性的内容?

2 个答案:

答案 0 :(得分:1)

尝试这个

[_segmentedControl.subviews enumerateObjectsUsingBlock:^(UIView * obj, NSUInteger idx, BOOL *stop) {
    [obj.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        if ([obj isKindOfClass:[UILabel class]]) {
            UILabel *lblCaption = (UILabel *)obj;
            lblCaption.minimumFontSize=10.0f;
//OR
            lblCaption.minimumFontSize = 0.5f;
        }
    }];     
}];

答案 1 :(得分:1)

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

C:\Program Files (x86)\MSBuild\14.0\bin\csc2.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentro.....
     Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
        at System.Collections.Immutable.SecurePooledObject`1.Use[TCaller](TCaller& caller)
        at System.Collections.Immutable.SortedInt32KeyNode`1.Enumerator.PushLeft(SortedInt32KeyNode`1 node)
        at System.Collections.Immutable.SortedInt32KeyNode`1.Enumerator..ctor(SortedInt32KeyNode`1 root)
        at System.Collections.Immutable.ImmutableDictionary`2.Enumerator..ctor(SortedInt32KeyNode`1 root, Builder builder)
        at Microsoft.CodeAnalysis.RuleSet.GetDiagnosticOptionsFromRulesetFile(Dictionary`2 diagnosticOptions, String resolvedPath, IList`1 diagnosticsOpt, CommonMessageProvider messageProviderOpt)
        at Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Parse(IEnumerable`1 args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.CommonParse(IEnumerable`1 args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CommonCompiler..ctor(CommandLineParser parser, String responseFile, String[] args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CSharp.CSharpCompiler..ctor(CSharpCommandLineParser parser, String responseFile, String[] args, String baseDirectory, String additionalReferencePaths)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc..ctor(String responseFile, String baseDirectory, String[] args)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(String[] args)
        at Microsoft.CodeAnalysis.BuildTasks.BuildClient.RunWithConsoleOutput(String[] args, RequestLanguage language, Func`2 fallbackCompiler)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)
        at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc2.Main(String[] args)