【问题标题】:Increase distance between inner view and segmented control layer增加内部视图和分段控制层之间的距离
【发布时间】:2020-05-13 01:48:24
【问题描述】:

我的应用中有分段控制。到目前为止,我如下图所示:

有什么方法可以改变内部视图层(所选段的白色视图)和分段控件层之间的距离,使其如下图所示?

这是我的分段控制代码:

private let segmentedControl: UISegmentedControl = {
    let control = UISegmentedControl(items: ["My likes", "Inbox"])
    control.backgroundColor = AppColor.segmented.uiColor.withAlphaComponent(0.1)
    control.layer.cornerRadius = 10
    control.selectedSegmentIndex = 0
    return control
}()

P/S。我知道我可以在没有分段控制但使用按钮的情况下做到这一点。

【问题讨论】:

    标签: ios swift uikit uisegmentedcontrol


    【解决方案1】:

    我认为使用按钮制作自定义视图的最佳方式。因为这种风格的段控件只在 ios 13+ 中可用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-26
      • 1970-01-01
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      相关资源
      最近更新 更多