喜欢←划,不喜欢→划

作者: c4ibD3 | 来源:发表于2017-02-26 21:37 被阅读735次

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

相关文章

  • 喜欢←划,不喜欢→划

    TanTan 探探 和 陌陌 都有 前提 现在比较流行的社交软件都有这么一个功能模块,喜欢←划,不喜欢→划, 多么...

  • Android右划喜欢左划不喜欢的View

    最近,额,不对,挺久之前,有一类交友APP,喜欢的右划,不喜欢的左划。看到的时候感觉还挺新鲜的,就琢磨着自己整一波...

  • 我喜欢以前的那个自己

    不喜欢和喜欢的界限划得非常清晰,喜欢就是喜欢,不喜欢就是不喜欢,没有那么多“灰色地带”。 所有的情绪都表露在脸上,...

  • 划, 划过。 流星划过夜空, 像聚了光的泪珠, 明的,亮的,消失的, 是诚心掉落尘土后无果的许愿书。 锄刀划过麦田...

  • 划空为界, 记时称世。 万物一马, 天地一指。

  • 我真的不喜欢游泳

    这次确定了,我真的不喜欢游泳。 当我独自一人在泳池里,泳镜里的双眼盯着前方宁静幽深的水底;双臂疲惫地划向后划,狡猾...

  • Row row row row your boat

    Row, row,row your boat 划阿划,划阿划,划大船 Row, row, row your boa...

  • 划水

    5个小时无心工作,只想划呀划呀划呀划

  • 心情日记

    喜欢你的,你什么都是好的! 不喜欢你的,别强求,别幻想! 划重点:别幻想!!! 一定要逼自己洒脱放手!!!!

  • 划向人生划向内心

    我撑起了杆 你划起了桨 我们划过星空 划过银河 划过了彩云 我摆起了舵 你挺立船头 我们欣赏着两岸风景 春天鸟语花...

网友评论

  • jisa:对手势移动时的旋转和缩放处理很COOL。学习了。:+1:
    c4ibD3:@jisa 谢谢你的赞赏,如果有什么使用问题,欢迎提意见
  • 我在鄱阳湖边:COOL!
    c4ibD3:@我在鄱阳湖边 谢谢 希望多提意见

本文标题:喜欢←划,不喜欢→划

本文链接:https://www.haomeiwen.com/subject/xodawttx.html