喜欢←划,不喜欢→划
生活随笔
收集整理的這篇文章主要介紹了
喜欢←划,不喜欢→划
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
TanTan
探探 和 陌陌 都有
前提
現在比較流行的社交軟件都有這么一個功能模塊,喜歡←劃,不喜歡→劃, 多么經典的一個廣告語啊。
我就在業余時間寫了這么一個demo樣例
這兩個都是比較參數經典的案例
參數
//代理 @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)indexreusingView:(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演示
傳送門
github:https://github.com/cAibDe/TanTan
總結
以上是生活随笔為你收集整理的喜欢←划,不喜欢→划的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: QQ开发技术资料集锦
- 下一篇: http状态码610,613