gpt4 book ai didi

ios - 以下哪项将设置UISegmentedControl的字体?

转载 作者:行者123 更新时间:2023-12-01 20:06:55 25 4
gpt4 key购买 nike

  • UIFont font = [UIFont boldSystemFontOfSize: 12.0f];
    NSDictionary attributes = [NSDictionary dictionaryWithObject: font forKey: UITextAttributeFont];
    [segmentedControl setTitleTextAttributes: attributes forState: UIControlStateNormal];
  • [[UISegmentedControl appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"STHeitiSC-Medium" size:13.0], UITextAttributeFont, nil] forState:UIControlStateNormal];
  • segmentedControl.transform = CGAffineTransformMakeScale(.6f, .6f);
  • 这些都不是。
  • 最佳答案

    UIFont font = [UIFont boldSystemFontOfSize: 12.0f];
    NSDictionary attributes = [NSDictionary dictionaryWithObject: font forKey: UITextAttributeFont];
    [segmentedControl setTitleTextAttributes: attributes forState: UIControlStateNormal];

    上面的代码将更改一个特定segmentControl的字体,而下面的代码将更改您应用中所有segmentControl的字体。
    [[UISegmentedControl appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"STHeitiSC-Medium" size:13.0], UITextAttributeFont, nil] forState:UIControlStateNormal];

    而此代码 segmentedControl.transform = CGAffineTransformMakeScale(.6f, .6f);只会缩小您的segmentcontrol

    注意:

    只需将废弃的 UITextAttributeFont替换为 NSFontAttributeName即可工作,而不会发出警告。

    关于ios - 以下哪项将设置UISegmentedControl的字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38630558/

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