【问题标题】:swift - add subview to segment control causes invalid behaviorswift - 将子视图添加到段控制会导致无效行为
【发布时间】:2018-06-23 15:26:51
【问题描述】:

我有一个段控制

let mySegmentControl = UISegmentedControl()

我为它添加了两个标题

mySegmentControl.setTitle(title: "one", forSegmentAt: 0)
mySegmentControl.setTitle(title: "two", forSegmentAt: 1)

我为“一”添加了标签徽章

let myBagdeLabel = UILable(badgeText: "0")
mySegmentControl.addSubView(myBagdeLabel)

the issue is: when "one" is seleted the myBagdeLabel is displayed behind the background color.我做了搜索,但没有看到任何代码来解决这个问题。看我的照片。

【问题讨论】:

    标签: ios swift controls badge segment


    【解决方案1】:

    试试mySegmentControl.bringSubview(toFront: myBadgeLabel)

    【讨论】:

    • 试过了,但没有成功 mySegmentControl.addSubView(myBagdeLabel) 已经把 myBagdeLabel 带到了顶部
    猜你喜欢
    • 2016-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多