UICollectionViewCell定制Button

 

效果

UICollectionViewCell定制Button

 

特点

1.能够动态设置每行显示的按钮的个数,以及控件的摆放格式

2.实现单选或者多选的功能,实现点击事件

3.自定制按钮的显示样式

 

用法

1.下载源码后,将文件中的GridCollectionView.h/.m文件,  CustomCollectionViewCell.h/.m文件,  TypeCellClass.h/.m文件导入工程中.

2.注意:你所创建的cell要继承CustomCollectionViewCell.然后你的cell上实现他所继承的类的几个方法,并创建你想要的界面.

3.在控制器中导入相关头文件,具体用法,参考源码.

 

源码

github:https://github.com/makingitbest/Button-CollectionView

 

细节

1.在UICollectionViewCell的基础上,给了几个方法,方便以后你在上面定制将要显示的控件,本demo是加载的button

UICollectionViewCell定制Button

 

2.给这个类,是为了在外部传入注册的cell类型.标识符

UICollectionViewCell定制Button

 

3. 对UICollectionView的封装

UICollectionViewCell定制Button

UICollectionViewCell定制Button

以上都是底层的封装.

4.具体的操作如下:

UICollectionViewCell定制Button

 

5.它有一个协议,处理点击事件的

UICollectionViewCell定制Button

 

6.单选和多选的状态设定在各自cell的内部处理

UICollectionViewCell定制Button

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案