UIScrollview一直显示滚动条,使用UIImageView自定义滚动条
2014-12-15 18:32
453 查看
UIScrollview一直显示滚动条,使用UIImageView自定义滚动条
@interface ViewController ()<UIScrollViewDelegate>
{
UIScrollView *backScrollView;
UIImageView *scrollIndexerImageView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
backScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 20, 200, 300)];
backScrollView.backgroundColor =
[UIColor greenColor];
backScrollView.contentSize = CGSizeMake(200, 900);
backScrollView.showsHorizontalScrollIndicator = NO;
backScrollView.showsVerticalScrollIndicator = NO;
backScrollView.delegate = self;
[self.view addSubview:backScrollView];
scrollIndexerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(backScrollView.frame.size.width-8, 0, 8,30)];
scrollIndexerImageView.image =
[UIImage imageNamed:@"teacherlist_select_scrollbar"];
[backScrollView addSubview:scrollIndexerImageView];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
float p = 0;
p = scrollView.contentOffset.y/(scrollView.contentSize.height -
scrollView.frame.size.height+(scrollIndexerImageView.frame.size.height-scrollIndexerImageView.frame.size.height*scrollView.frame.size.height/scrollView.contentSize.height));
scrollIndexerImageView.frame = CGRectMake(backScrollView.frame.size.width-8,p*scrollView.contentSize.height,8,30);
NSLog(@"y:%f",scrollView.contentOffset.y);
NSLog(@"--:%f",scrollIndexerImageView.frame.origin.y);
}
原文地址:http://www.wahenzan.com/a/mdev/ios/2014/1215/350.html
@interface ViewController ()<UIScrollViewDelegate>
{
UIScrollView *backScrollView;
UIImageView *scrollIndexerImageView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
backScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 20, 200, 300)];
backScrollView.backgroundColor =
[UIColor greenColor];
backScrollView.contentSize = CGSizeMake(200, 900);
backScrollView.showsHorizontalScrollIndicator = NO;
backScrollView.showsVerticalScrollIndicator = NO;
backScrollView.delegate = self;
[self.view addSubview:backScrollView];
scrollIndexerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(backScrollView.frame.size.width-8, 0, 8,30)];
scrollIndexerImageView.image =
[UIImage imageNamed:@"teacherlist_select_scrollbar"];
[backScrollView addSubview:scrollIndexerImageView];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
float p = 0;
p = scrollView.contentOffset.y/(scrollView.contentSize.height -
scrollView.frame.size.height+(scrollIndexerImageView.frame.size.height-scrollIndexerImageView.frame.size.height*scrollView.frame.size.height/scrollView.contentSize.height));
scrollIndexerImageView.frame = CGRectMake(backScrollView.frame.size.width-8,p*scrollView.contentSize.height,8,30);
NSLog(@"y:%f",scrollView.contentOffset.y);
NSLog(@"--:%f",scrollIndexerImageView.frame.origin.y);
}
原文地址:http://www.wahenzan.com/a/mdev/ios/2014/1215/350.html
相关文章推荐
- 如何使UIScrollView的滚动条indicator一直显示
- 让UIScrollView、UITableView的滚动条一直显示
- 如何一直显示tableview的滚动条(自定义方法)
- 将UIScrollView的滚动条一直显示
- 如何使UIScrollView的滚动条indicator一直显示
- 如何使UIScrollView的滚动条indicator一直显示
- 一直显示UIScrollView的Indicators,即滚动条
- 如何使UIScrollView的滚动条indicator一直显示
- 自定义导航栏的时候使用UIImagePickerViewControlle Item无法正常显示
- UIScrollView 的滚动条 一直显示的方法
- UIScrollView一直显示滚动条
- 如何使UIScrollView的滚动条indicator一直显示
- UIScrollView/UITableView 一直显示滚动条(ScrollBar Indicators)、滚动条Width(宽度)、滚动条Color(颜色)
- [IOS]使用UIScrollView和UIPageControl显示半透明帮助蒙板
- 02-常见控件:UILabel(显示文本)、UIImageView(图片视图)、UISlider(滑动器)、UISwitch(开关)、UIStepper(计数器)、UIToolbar(工具栏)的使用
- IOS使用UIImageView显示gif动画的例子
- UITableView 一直显示滚动条(ScrollBar Indicators)、滚动条Width(宽度)、滚动条Color(颜色)
- android使用WindowManager显示自定义View
- [IOS] 使用UIImageView的contentMode属性, 控制图片显示
- 自定义UIScrollView 滚动条(适合大部分继承自UIScrollView的控件,如UITextView,UITableView等)