滚动条只是显示作用,不能点击拖动。
当然可以根据自定义样式。
想法很简单,就是在UIScrollView里面先增加一个竖条,在增加一个图标。
通过移动UIScrollView里面的坐标,来实现图标移动的效果。
当然可以根据自定义样式。
想法很简单,就是在UIScrollView里面先增加一个竖条,在增加一个图标。
通过移动UIScrollView里面的坐标,来实现图标移动的效果。
UIScrollView *leftScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 40, 200, 630)];
leftScroll.delegate = self;
leftScroll.showsVerticalScrollIndicator = NO;
leftScroll.bounces = NO;
[self.view addSubview:leftScroll];
// 添加 竖条
NSString *pathS = [[NSBundle mainBundle] pathForResource:@"ss" ofType:@"png"];
UIImage *imageS = [[UIImage alloc] initWithContentsOfFile:pathS];
UIImageView *imageSView = [[UIImageView alloc] initWithImage:imageS];
imageSView.frame = CGRectMake(190,0,2,200*[arr count]);
[leftScroll addSubview:imageSView];
// 添加 图标
pathS = [[NSBundle mainBundle] pathForResource:@"gg" ofType:@"png"];
imageS = [[UIImage alloc] initWithContentsOfFile:pathS];
imageGView = [[UIImageView alloc] initWithImage:imageS];
imageGView.frame = CGRectMake(186,10,10,27);
[leftScroll addSubview:imageGView];
// 当移动调用此方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
float p = 0;
p = scrollView.contentOffset.y/(scrollView.contentSize.height - scrollView.frame.size.height);
imageGView.frame = CGRectMake(186,p*scrollView.contentSize.height,10, 27);
}