XLPagerTabStrip在IOs Swift View Pager中添加图像和标签

Shy*_*Deb 2 ios swift xlpagertabstrip

我正在使用View寻呼机应用程序制作应用程序,我正在使用XLPagerTabStrip库来制作它.它在Viewpager项目中与Title一起使用.我想在其中添加Icon和相应的Label.

Jai*_*hew 6

崩溃背后的原因是,ButtonCell.xib中缺少UIImageView.

解决方案是:

  1. 打开ButtonBarViewCell类,从xcode的顶部导航菜单中,单击ButtonBarViewCell.可以看到ButtonCell.xib.
  2. 打开ButtonCell.xib,将UIImage视图拖放到单元格的中心.应用Constrains并将其连接到IBOutlet imageView.
  3. 回到ButtonBarViewCell类并在func willMove(toSuperview newSuperview:UIView?)函数中添加这行代码.

如果imageView.superview!= nil {contentView.addSubview(imageView)}

4.返回实现页面的类并添加此代码

 func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
    return IndicatorInfo(title: "",image: UIImage(named: "camera.png"))
}  
Run Code Online (Sandbox Code Playgroud)

5.done

`