喜欢←划,不喜欢→划

TanTan

探探 和 陌陌 都有

前提

现在比较流行的社交软件都有这么一个功能模块,喜欢←划,不喜欢→划, 多么经典的一个广告语啊。
我就在业余时间写了这么一个demo样例

WechatIMG1.jpeg

WechatIMG2.jpeg

这两个都是比较参数经典的案例

参数

//代理
@property (nonatomic, weak) id<TanTanDelegate>delegate;
//数据源
@property (nonatomic, weak) id<TanTanDataSource>dataSource;
//是否设置循环
@property (nonatomic, assign) BOOL isCyclically;
//展示出来的item数目
@property (nonatomic, assign) NSInteger showItemsNumber;
//设置偏移量
@property (nonatomic, assign) CGSize offSet;
//显示的第一个View
@property (nonatomic, strong , readonly) UIView *topView;
//刷新展示数据
- (void)refreshData;

我们可以通过设置isCyclically来实现视图是否循环,通过offset来设置重叠视图的重叠方向 `

@protocol TanTanDataSource <NSObject>
@required
- (NSInteger)numberOfItemInTanTan:(TanTanView *)tantan;

- (UIView *)tantan:(TanTanView *)tantan
viewForItemAtIndex:(NSInteger)index
       reusingView:(UIView *)view;
@end

上面的这个是数据源,这两个方法的思路和UITableView的数据源差不多,一个是设置数据源数目,一个就是视图复用

@protocol TanTanDelegate <NSObject>
@optional
- (void)tantan:(TanTanView *)tantan beforeSwipingItemAtIndex:(NSInteger)index;
- (void)tantan:(TanTanView *)tantan didRemovedItemAtIndex:(NSInteger)index;
- (void)tantan:(TanTanView *)tantan didLeftRemovedItemAtIndex:(NSInteger)index;
- (void)tantan:(TanTanView *)tantan didRightRemovedItemAtIndex:(NSInteger)index;

这就是相应的代理方法

GIF演示

探探.gif

传送门

github:https://github.com/cAibDe/TanTan

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,990评论 25 709
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,838评论 19 139
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,435评论 4 61
  • 这周一开始每天晚上和家人一起做两到三次五行健康操,这也是上次去上海刚学的一个挺不错的健康操,不用受场地限制,在家...
    云沐妈妈阅读 1,648评论 0 0
  • 我是日记星球的12号星宝宝,正在参加孙老师的日记星球21天蜕变之旅第三期的写作训练。我相信日积月累,滴水穿石的力量...
    筱万阅读 1,337评论 0 2

友情链接更多精彩内容