BGSwipeView.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // BGSwipeView.h
  3. // BuguLive
  4. //
  5. // Created by 朱庆彬 on 2017/8/16.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #pragma GCC diagnostic push
  9. #pragma GCC diagnostic ignored "-Wauto-import"
  10. #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis"
  11. #import <Availability.h>
  12. #undef weak_delegate
  13. #if __has_feature(objc_arc) && __has_feature(objc_arc_weak)
  14. #define weak_delegate weak
  15. #else
  16. #define weak_delegate unsafe_unretained
  17. #endif
  18. #import <UIKit/UIKit.h>
  19. typedef NS_ENUM(NSUInteger, FWSwipeViewAlignment) {
  20. FWSwipeViewAlignmentEdge = 0,
  21. FWSwipeViewAlignmentCenter
  22. };
  23. @protocol FWSwipeViewDataSource
  24. , FWSwipeViewDelegate;
  25. @interface BGSwipeView : UIView
  26. @property (nonatomic, weak_delegate) IBOutlet id<FWSwipeViewDataSource> dataSource;
  27. @property (nonatomic, weak_delegate) IBOutlet id<FWSwipeViewDelegate> delegate;
  28. @property (nonatomic, readonly) NSInteger numberOfItems;
  29. @property (nonatomic, readonly) NSInteger numberOfPages;
  30. @property (nonatomic, readonly) CGSize itemSize;
  31. @property (nonatomic, assign) NSInteger itemsPerPage;
  32. @property (nonatomic, assign) BOOL truncateFinalPage;
  33. @property (nonatomic, strong, readonly) NSArray *indexesForVisibleItems;
  34. @property (nonatomic, strong, readonly) NSArray *visibleItemViews;
  35. @property (nonatomic, strong, readonly) UIView *currentItemView;
  36. @property (nonatomic, assign) NSInteger currentItemIndex;
  37. @property (nonatomic, assign) NSInteger currentPage;
  38. @property (nonatomic, assign) FWSwipeViewAlignment alignment;
  39. @property (nonatomic, assign) CGFloat scrollOffset;
  40. @property (nonatomic, assign, getter=isPagingEnabled) BOOL pagingEnabled;
  41. @property (nonatomic, assign, getter=isScrollEnabled) BOOL scrollEnabled;
  42. @property (nonatomic, assign, getter=isWrapEnabled) BOOL wrapEnabled;
  43. @property (nonatomic, assign) BOOL delaysContentTouches;
  44. @property (nonatomic, assign) BOOL bounces;
  45. @property (nonatomic, assign) float decelerationRate;
  46. @property (nonatomic, assign) CGFloat autoscroll;
  47. @property (nonatomic, readonly, getter=isDragging) BOOL dragging;
  48. @property (nonatomic, readonly, getter=isDecelerating) BOOL decelerating;
  49. @property (nonatomic, readonly, getter=isScrolling) BOOL scrolling;
  50. @property (nonatomic, assign) BOOL defersItemViewLoading;
  51. @property (nonatomic, assign, getter=isVertical) BOOL vertical;
  52. - (void)reloadData;
  53. - (void)reloadItemAtIndex:(NSInteger)index;
  54. - (void)scrollByOffset:(CGFloat)offset duration:(NSTimeInterval)duration;
  55. - (void)scrollToOffset:(CGFloat)offset duration:(NSTimeInterval)duration;
  56. - (void)scrollByNumberOfItems:(NSInteger)itemCount duration:(NSTimeInterval)duration;
  57. - (void)scrollToItemAtIndex:(NSInteger)index duration:(NSTimeInterval)duration;
  58. - (void)scrollToPage:(NSInteger)page duration:(NSTimeInterval)duration;
  59. - (UIView *)itemViewAtIndex:(NSInteger)index;
  60. - (NSInteger)indexOfItemView:(UIView *)view;
  61. - (NSInteger)indexOfItemViewOrSubview:(UIView *)view;
  62. @end
  63. @protocol FWSwipeViewDataSource <NSObject>
  64. - (NSInteger)numberOfItemsInFWSwipeView:(BGSwipeView *)swipeView;
  65. - (UIView *)swipeView:(BGSwipeView *)swipeView viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view;
  66. @end
  67. @protocol FWSwipeViewDelegate <NSObject>
  68. @optional
  69. - (CGSize)swipeViewItemSize:(BGSwipeView *)swipeView;
  70. - (void)swipeViewDidScroll:(BGSwipeView *)swipeView;
  71. - (void)swipeViewCurrentItemIndexDidChange:(BGSwipeView *)swipeView;
  72. - (void)swipeViewWillBeginDragging:(BGSwipeView *)swipeView;
  73. - (void)swipeViewDidEndDragging:(BGSwipeView *)swipeView willDecelerate:(BOOL)decelerate;
  74. - (void)swipeViewWillBeginDecelerating:(BGSwipeView *)swipeView;
  75. - (void)swipeViewDidEndDecelerating:(BGSwipeView *)swipeView;
  76. - (void)swipeViewDidEndScrollingAnimation:(BGSwipeView *)swipeView;
  77. - (BOOL)swipeView:(BGSwipeView *)swipeView shouldSelectItemAtIndex:(NSInteger)index;
  78. - (void)swipeView:(BGSwipeView *)swipeView didSelectItemAtIndex:(NSInteger)index;
  79. @end
  80. #pragma GCC diagnostic pop