最近項目循環效果的列表,我在網上搜到一個隻有類似效果的例子,我在這個例子的基礎之上加入瞭對應的響應事件。1、滑動到中間的響應事件
2、滑動結束的響應事件。
ViewController.h
#import #import InfiniteScrollPicker.h @interface ViewController : UIViewController @property (strong , nonatomic) InfiniteScrollPicker* m_InfiniteScroll; @property (strong , nonatomic) UILabel* m_labelTest; @end
ViewController.m
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSMutableArray* set1 = [[NSMutableArray alloc] init]; for (int i = 0; i < 40; i++) { UIImage* img = [UIImage imageNamed:[NSString stringWithFormat:@s1_0.png,i]]; [set1 addObject:img]; } self.m_InfiniteScroll = [[InfiniteScrollPicker alloc] initWithFrame:CGRectMake(0, 448, 320, 100)]; self.m_InfiniteScroll.backgroundColor = [UIColor redColor]; self.m_InfiniteScroll.Infinitedelegate = self; [self.m_InfiniteScroll setItemSize:CGSizeMake(50, 50)]; [self.m_InfiniteScroll setImageAry:set1]; [self.view addSubview:self.m_InfiniteScroll]; // self.view.transform = CGAffineTransformMakeRotation(M_PI / 2); [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight; self.m_labelTest = [[UILabel alloc] initWithFrame:CGRectMake(100, 300, 100, 50)]; [self.view addSubview:self.m_labelTest]; } -(BOOL)shouldAutorotate { return NO; } #pragma mark- InfiniteScrollPickerDelegate /*點擊單張圖片的回調*/ -(void)tapImageViewMethod:(UIGestureRecognizer *)gesture { self.m_labelTest.text = [NSString stringWithFormat:@%d,gesture.view.tag]; NSLog(@gesture.view.tag = %d,gesture.view.tag); } /*滑動時的回調*/ -(void)sliderInfiniteScrollView:(UIView *)view { self.m_labelTest.text = [NSString stringWithFormat:@%d,view.tag]; NSLog(@slider view.tag = %d,view.tag); } /*結束時的回調*/ -(void)infiniteScrollPicker:(InfiniteScrollPicker *)infiniteScrollPicker didSelectAtImageView:(UIView *)view { self.m_labelTest.text = [NSString stringWithFormat:@%d,view.tag]; NSLog(@stop image tag= %d,view.tag); }