Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何向按钮动态添加徽章?_Ios_Swift_Xlpagertabstrip - Fatal编程技术网

Ios 如何向按钮动态添加徽章?

Ios 如何向按钮动态添加徽章?,ios,swift,xlpagertabstrip,Ios,Swift,Xlpagertabstrip,当我从DB收到新的更新时,我想在选项卡中添加一个徽章。是否有一种方法可以调用以更新指示信息 无法理解,请帮助。我不得不处理XIB文件,设置约束条件并手动处理案例 执行的步骤 向按钮cell.xib文件中的UIImageView添加约束,使其自身与UILabel对齐。(我在ui视图中添加了它们,以确保视图居中。) 更改为按钮BaragerTabStripViewController中的以下代码 buttonBarItemSpec = .nibFile(nibName: "ButtonCell",

当我从DB收到新的更新时,我想在选项卡中添加一个徽章。是否有一种方法可以调用以更新
指示信息


无法理解,请帮助。

我不得不处理XIB文件,设置约束条件并手动处理案例

执行的步骤
  • 按钮cell.xib
    文件中的
    UIImageView
    添加约束,使其自身与
    UILabel
    对齐。(我在
    ui视图中添加了它们,以确保视图居中。)
  • 更改为
    按钮BaragerTabStripViewController中的以下代码

    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
    ,并将图像不应存在时的
    常量值设置为
    0.0

  • tabbarcontroller的选项卡?没有分页菜单viewcontroller pod。谢谢我试过了,但它要么有标题,要么有图像。我有一个标题,还动态添加了一个徽章。您是否正在尝试在
    UITabBarController
    的选项卡上设置徽章?