日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

喜欢←划,不喜欢→划

發布時間:2023/12/31 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 喜欢←划,不喜欢→划 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

總結

以上是生活随笔為你收集整理的喜欢←划,不喜欢→划的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。