代码之家  ›  专栏  ›  技术社区  ›  BARS

UISegmentController标题文本剪切得很奇怪

  •  -1
  • BARS  · 技术社区  · 7 年前

    enter image description here

    它是用Objective-C编程编写的。UISegmentController正在剪切标题文本。

    隐私政策 '全文比' 关于 '和' 条款

    有人能帮忙吗?

        UISegmentedControl *unitsPicker                     = [[UISegmentedControl alloc] initWithItems:@[@"About", @"Terms", @"Privacy Policy"]];
        unitsPicker.frame                   = CGRectMake(0, CGRectGetMaxY(unitsLabel.frame) + kBottomPaddingConstant, CGRectGetWidth(_unitsContainer.frame), segmentHeightConstant);
        unitsPicker.autoresizingMask        = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
        unitsPicker.selectedSegmentIndex    = ![TemperatureUtility unitIsCelsius];
        [unitsPicker addTarget:self action:@selector(onUnitPickerChanged:) forControlEvents:UIControlEventValueChanged];
        unitsPicker.layer.cornerRadius   = 5.0f;
        unitsPicker.layer.borderColor    = [UIColorFromRGB(0xE9E9E9) CGColor];
        unitsPicker.layer.borderWidth    = 1.0f;
        unitsPicker.layer.masksToBounds  = YES;
        unitsPicker.clipsToBounds        = YES;
        [_unitsContainer addSubview:unitsPicker];
    
    1 回复  |  直到 7 年前
        1
  •  -1
  •   koen    7 年前

    尝试设置:

    segmentedControl.apportionsSegmentWidthsByContent = YES;

    如果此属性的值为true,则对于宽度值为0的段,控件将尝试根据其内容宽度调整段宽度。 默认值为false。