如何动态添加徽章到按钮?

时间:2017-10-24 04:32:12

标签: ios swift xlpagertabstrip

我想从DB收到新的更新时向标签添加徽章。有没有我可以调用的方法来更新IndicatorInfo

无法弄清楚请帮助。

1 个答案:

答案 0 :(得分:1)

我必须使用XIB文件,并手动设置约束和处理案例。

执行的步骤

  1. ButtonCell.xib文件中的UILabel添加约束,使其自身与UIView对齐。 (我在ButtonBaragerTabStripViewController上添加了它们,以确保视图居中。)
  2. 已更改为buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width: { [weak self] (childItemInfo) -> CGFloat in let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.font = self?.settings.style.buttonBarItemFont label.text = childItemInfo.title let labelSize = label.intrinsicContentSize return labelSize.width + (childItemInfo.image != nil ? 35.0 : 0.0) + (self?.settings.style.buttonBarItemLeftRightMargin ?? 8) * 2 })

    中的以下代码
    @IBOutlet
  3. 添加约束constant并将0.0值设置为sed,当图片不应该在那里时。
相关问题