### Carthage installation Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md Add the GitHub repository to your Cartfile to install TYCyclePagerView via Carthage. ```ruby github "12207480/TYCyclePagerView" ``` -------------------------------- ### CocoaPods installation Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md Add the pod to your Podfile to install TYCyclePagerView via CocoaPods. ```ruby pod 'TYCyclePagerView' ``` -------------------------------- ### Usage: addPagerView, addPageControl, and loadData Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md Example methods to set up the pager view, add a page control, and load data. The pager view is configured with infinite loop and auto-scroll; the page control is added as a subview; loadData updates the page count and reloads. ```objc - (void)addPagerView { TYCyclePagerView *pagerView = [[TYCyclePagerView alloc]init]; pagerView.layer.borderWidth = 1; pagerView.isInfiniteLoop = YES; pagerView.autoScrollInterval = 3.0; pagerView.dataSource = self; pagerView.delegate = self; // registerClass or registerNib [pagerView registerClass:[TYCyclePagerViewCell class] forCellWithReuseIdentifier:@"cellId"]; [self.view addSubview:pagerView]; _pagerView = pagerView; } - (void)addPageControl { TYPageControl *pageControl = [[TYPageControl alloc]init]; //pageControl.numberOfPages = _datas.count; pageControl.currentPageIndicatorSize = CGSizeMake(8, 8); // pageControl.pageIndicatorImage = [UIImage imageNamed:@"Dot"]; // pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"DotSelected"]; // [pageControl addTarget:self action:@selector(pageControlValueChangeAction:) forControlEvents:UIControlEventValueChanged]; [_pagerView addSubview:pageControl]; _pageControl = pageControl; } - (void)loadData { // load data to _datas _pageControl.numberOfPages = _datas.count; [_pagerView reloadData]; } ``` -------------------------------- ### TYCyclePagerView DataSource and Delegate protocols Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md Define the data source and delegate methods for TYCyclePagerView. The data source provides the number of items, cells, and layout; the delegate handles scroll and selection events. ```objc @protocol TYCyclePagerViewDataSource - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)pageView; - (__kindof UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index; /** return pagerView layout,and cache layout */ - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)pageView; @protocol TYCyclePagerViewDelegate @optional /** pagerView did scroll to new index page */ - (void)pagerView:(TYCyclePagerView *)pageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex; /** pagerView did selected item cell */ - (void)pagerView:(TYCyclePagerView *)pageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index; // More API see project ``` -------------------------------- ### TYCyclePagerViewDelegate Protocol Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md The delegate protocol for TYCyclePagerView. Optional methods to handle scroll events and item selection. ```APIDOC ## TYCyclePagerViewDelegate Protocol ### Description Optional delegate methods for TYCyclePagerView to handle scroll and selection events. ### Methods #### pagerView:didScrollFromIndex:toIndex: - **pagerView:** (TYCyclePagerView *)pageView - Required - The pager view that scrolled. - **didScrollFromIndex:** (NSInteger)fromIndex - Required - The index before scrolling. - **toIndex:** (NSInteger)toIndex - Required - The index after scrolling. #### pagerView:didSelectedItemCell:atIndex: - **pagerView:** (TYCyclePagerView *)pageView - Required - The pager view that was selected. - **didSelectedItemCell:** (__kindof UICollectionViewCell *)cell - Required - The selected cell. - **atIndex:** (NSInteger)index - Required - The index of the selected item. ### Example ```objc @protocol TYCyclePagerViewDelegate @optional /** pagerView did scroll to new index page */ - (void)pagerView:(TYCyclePagerView *)pageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex; /** pagerView did selected item cell */ - (void)pagerView:(TYCyclePagerView *)pageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index; ``` ``` -------------------------------- ### TYCyclePagerView, TYCyclePagerViewLayout, and TYPageControl class interfaces Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md Public interfaces for the main classes. TYCyclePagerView manages the pager, TYCyclePagerViewLayout defines layout properties, and TYPageControl provides page indicator customization. ```objc @interface TYCyclePagerView : UIView // will be automatically resized to track the size of the pagerView @property (nonatomic, strong, nullable) UIView *backgroundView; @property (nonatomic, weak, nullable) id dataSource; @property (nonatomic, weak, nullable) id delegate; // pager view layout is important @property (nonatomic, strong, readonly) TYCyclePagerViewLayout *layout; /** is infinite cycle pageview */ @property (nonatomic, assign) BOOL isInfiniteLoop; /** pagerView automatic scroll time interval, default 0,disable automatic */ @property (nonatomic, assign) CGFloat autoScrollInterval; @interface TYCyclePagerViewLayout : NSObject @property (nonatomic, assign) CGSize itemSize; @property (nonatomic, assign) CGFloat itemSpacing; @property (nonatomic, assign) UIEdgeInsets sectionInset; @property (nonatomic, assign) TYCyclePagerTransformLayoutType layoutType; @property (nonatomic, assign) CGFloat minimumScale; // sacle default 0.8 @property (nonatomic, assign) CGFloat minimumAlpha; // alpha default 1.0 @property (nonatomic, assign) CGFloat maximumAngle; // angle is % default 0.2 @interface TYPageControl : UIControl @property (nonatomic, assign) NSInteger numberOfPages; // default is 0 @property (nonatomic, assign) NSInteger currentPage; // default is 0. value pinned to 0..numberOfPages-1 // indicatorTint color @property (nullable, nonatomic,strong) UIColor *pageIndicatorTintColor; @property (nullable, nonatomic,strong) UIColor *currentPageIndicatorTintColor; // indicator image @property (nullable, nonatomic,strong) UIImage *pageIndicatorImage; @property (nullable, nonatomic,strong) UIImage *currentPageIndicatorImage; ``` -------------------------------- ### TYCyclePagerViewDataSource Protocol Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md The data source protocol for TYCyclePagerView. Implement these methods to provide the number of items and the cells for the pager view, as well as the layout. ```APIDOC ## TYCyclePagerViewDataSource Protocol ### Description Provides data to the TYCyclePagerView: number of items, cell for each index, and the layout. ### Methods #### numberOfItemsInPagerView: - **numberOfItemsInPagerView:** (TYCyclePagerView *)pageView - Required - Returns the number of items in the pager view. #### pagerView:cellForItemAtIndex: - **pagerView:** (TYCyclePagerView *)pagerView - Required - Returns the cell for the item at the given index. - **cellForItemAtIndex:** (NSInteger)index - Required - The index of the item. #### layoutForPagerView: - **layoutForPagerView:** (TYCyclePagerView *)pageView - Required - Returns the layout for the pager view. The layout is cached. ### Example ```objc @protocol TYCyclePagerViewDataSource - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)pageView; - (__kindof UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index; /** return pagerView layout,and cache layout */ - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)pageView; ``` ``` -------------------------------- ### TYCyclePagerViewLayout Class Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md Layout configuration for TYCyclePagerView. Controls item size, spacing, insets, and transform effects. ```APIDOC ## TYCyclePagerViewLayout Class ### Description Defines the layout properties for the pager view, including item size, spacing, and visual effects. ### Properties - **itemSize** (CGSize) - The size of each item. - **itemSpacing** (CGFloat) - The spacing between items. - **sectionInset** (UIEdgeInsets) - The inset for the section. - **layoutType** (TYCyclePagerTransformLayoutType) - The layout type for the pager view. - **minimumScale** (CGFloat) - The minimum scale for items. Default is 0.8. - **minimumAlpha** (CGFloat) - The minimum alpha for items. Default is 1.0. - **maximumAngle** (CGFloat) - The maximum angle for items. Default is 0.2. ### Example ```objc @interface TYCyclePagerViewLayout : NSObject @property (nonatomic, assign) CGSize itemSize; @property (nonatomic, assign) CGFloat itemSpacing; @property (nonatomic, assign) UIEdgeInsets sectionInset; @property (nonatomic, assign) TYCyclePagerTransformLayoutType layoutType; @property (nonatomic, assign) CGFloat minimumScale; // sacle default 0.8 @property (nonatomic, assign) CGFloat minimumAlpha; // alpha default 1.0 @property (nonatomic, assign) CGFloat maximumAngle; // angle is % default 0.2 ``` ``` -------------------------------- ### TYCyclePagerView Class Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md The main pager view class. Provides properties for data source, delegate, layout, infinite loop, and auto-scroll interval. ```APIDOC ## TYCyclePagerView Class ### Description A UIView subclass that displays a cycle pager view with auto-scroll and page control support. ### Properties - **backgroundView** (UIView, nullable) - A view that will be automatically resized to track the size of the pagerView. - **dataSource** (id, weak, nullable) - The data source for the pager view. - **delegate** (id, weak, nullable) - The delegate for the pager view. - **layout** (TYCyclePagerViewLayout, readonly) - The layout object for the pager view. - **isInfiniteLoop** (BOOL) - Whether the pager view loops infinitely. - **autoScrollInterval** (CGFloat) - The time interval for automatic scrolling. Default is 0, which disables auto-scroll. ### Example ```objc @interface TYCyclePagerView : UIView // will be automatically resized to track the size of the pagerView @property (nonatomic, strong, nullable) UIView *backgroundView; @property (nonatomic, weak, nullable) id dataSource; @property (nonatomic, weak, nullable) id delegate; // pager view layout is important @property (nonatomic, strong, readonly) TYCyclePagerViewLayout *layout; /** is infinite cycle pageview */ @property (nonatomic, assign) BOOL isInfiniteLoop; /** pagerView automatic scroll time interval, default 0,disable automatic */ @property (nonatomic, assign) CGFloat autoScrollInterval; ``` ``` -------------------------------- ### TYPageControl Class Source: https://github.com/12207480/tycyclepagerview/blob/master/README.md A page control for TYCyclePagerView. Provides properties for number of pages, current page, and indicator customization. ```APIDOC ## TYPageControl Class ### Description A UIControl subclass that displays page indicators for the pager view. ### Properties - **numberOfPages** (NSInteger) - The number of pages. Default is 0. - **currentPage** (NSInteger) - The current page. Default is 0. Value is pinned to 0..numberOfPages-1. - **pageIndicatorTintColor** (UIColor, nullable) - The tint color for page indicators. - **currentPageIndicatorTintColor** (UIColor, nullable) - The tint color for the current page indicator. - **pageIndicatorImage** (UIImage, nullable) - The image for page indicators. - **currentPageIndicatorImage** (UIImage, nullable) - The image for the current page indicator. ### Example ```objc @interface TYPageControl : UIControl @property (nonatomic, assign) NSInteger numberOfPages; // default is 0 @property (nonatomic, assign) NSInteger currentPage; // default is 0. value pinned to 0..numberOfPages-1 // indicatorTint color @property (nullable, nonatomic,strong) UIColor *pageIndicatorTintColor; @property (nullable, nonatomic,strong) UIColor *currentPageIndicatorTintColor; // indicator image @property (nullable, nonatomic,strong) UIImage *pageIndicatorImage; @property (nullable, nonatomic,strong) UIImage *currentPageIndicatorImage; ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.