iOS卡片容器iCards
2016-07-21 08:47
330 查看
项目中需要用卡片形式展示商家信息(当然这个展示风景和人物更好),希望左右滑动移除最上面的一张,卡片可以循环显示也可以不循环(即划走的再不见),GitHub上有类似项目,但都耦合在ViewController里,参考其实现封装了一个自定义view,取名iCards(因代理方法参考了第三方库iCarousel, 名称也学习了)。
iCards层叠显示卡片,每张卡片是任意view,你可以通过下边这个代理方法来定义:
iCards目前有4个属性,分别控制是否需要循环显示卡片、相邻卡片相对位移、可见的卡片数量(假设你有100张,但可见的可以只有3张)以及是否允许滑动
有两个方法,见名知义,不多说:
有两个数据源代理方法:
4个可选辅助代理方法:
以下是效果图:
iCards同样做了Pod支持。源码参见GitHub:iCards
iCards层叠显示卡片,每张卡片是任意view,你可以通过下边这个代理方法来定义:
- (UIView *)cards:(iCards *)cards viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view;
iCards目前有4个属性,分别控制是否需要循环显示卡片、相邻卡片相对位移、可见的卡片数量(假设你有100张,但可见的可以只有3张)以及是否允许滑动
/** default is YES*/ @property (nonatomic, assign) BOOL itemsShouldShowedCyclically; /** We will creat this number of views, so not too many; default is 3 */ @property (nonatomic, assign) NSInteger numberOfVisibleItems; /** offset for the next card to the current card, (it will decide the cards appearance, the top card is on top-left, top, or bottom-right and so on; default is (5, 5) */ @property (nonatomic, assign) CGSize offset; /** If there is only one card, maybe you don't want to swipe it; */ @property (nonatomic, assign) BOOL swipEnabled;
有两个方法,见名知义,不多说:
- (void)reloadData; - (UIView *)currentCard;
有两个数据源代理方法:
- (NSInteger)numberOfItemsInCards:(iCards *)cards; - (UIView *)cards:(iCards *)cards viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view;
4个可选辅助代理方法:
- (void)cards:(iCards *)cards beginSwipingItemAtIndex:(NSInteger)index; - (void)cards:(iCards *)cards didRemovedItemAtIndex:(NSInteger)index; - (void)cards:(iCards *)cards didLeftRemovedItemAtIndex:(NSInteger)index; - (void)cards:(iCards *)cards didRightRemovedItemAtIndex:(NSInteger)index;
以下是效果图:
iCards同样做了Pod支持。源码参见GitHub:iCards
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 更新linux底层库(openssl)
- 修复mysql数据库
- nodejs中的fiber(纤程)库详解
- 桌面中心(一)创建数据库
- 浅析C语言头文件和库的一些问题
- 桌面中心(三)修改数据库
- 目前流行的JavaScript库的介绍及对比
- 讲解iOS开发中基本的定位功能实现
- iOS中定位当前位置坐标及转换为火星坐标的方法
- js判断客户端是iOS还是Android等移动终端的方法
- iOS应用开发中AFNetworking库的常用HTTP操作方法小结
- iOS应用中UISearchDisplayController搜索效果的用法
- iOS App开发中的UISegmentedControl分段组件用法总结