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

时间:2017-01-21 13:33:54

标签: ios swift xlpagertabstrip

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

1 个答案:

答案 0 :(得分:6)

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

解决方案是:

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

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

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

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

    5.done

    `