UIScrollerView基础
来源:互联网 发布:剑三成男25号脸数据 编辑:程序博客网 时间:2024/04/25 21:17
#import "ViewController.h"
@interface ViewController ()
{
UIImageView *image;
UIScrollView *scrollerView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
scrollerView = [[UIScrollViewalloc]init];
scrollerView.frame =self.view.frame;
[self.viewaddSubview:scrollerView];
image = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0, 1600,1607)];
image.image = [UIImageimageNamed:@"IMG_2780"];
[scrollerView addSubview:image];
//设置滚动范围
scrollerView.contentSize =CGSizeMake(1600,1067);
//设置间距
scrollerView.contentInset =UIEdgeInsetsMake(50,50, 50, 50);
//设置初始偏移量
scrollerView.contentOffset =CGPointMake(100,100);
//隐藏水平滚动条
scrollerView.showsHorizontalScrollIndicator =NO;
//隐藏垂直滚动条
scrollerView.showsVerticalScrollIndicator =NO;
//弹簧效果
scrollerView.bounces =NO;
//是否允许与用户交互
scrollerView.userInteractionEnabled =YES;
UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(self.view.frame.size.width / 2, self.view.frame.size.height /2, 50,50);
[btn setTitle:@"滚动"forState:UIControlStateNormal];
[btn addTarget:selfaction:@selector(move)forControlEvents:UIControlEventTouchUpInside];
btn.titleLabel.textColor = [UIColorblackColor];
btn.titleLabel.font = [UIFontsystemFontOfSize:18];
[self.viewaddSubview:btn];
}
- (void)move{
CGPoint offSet =scrollerView.contentOffset;
offSet.x +=50;
// scrollerView.contentOffset = offSet;
[UIViewanimateWithDuration:1animations:^{
scrollerView.contentOffset = offSet;
}];
}
- UIScrollerView基础
- UIScrollerView
- UIScrollerView
- 关于UIScrollerView
- UIScrollerView 属性的总结
- UIScrollerView的学习笔记
- UIScrollerview详解,配合UIPageControl
- UIScrollerView 无限滚动视图
- UIScrollerView滚动方向判断
- UIScrollerView约束注意点
- UIScrollerView 实现轮播图功能
- UIScrollerView一直显示
- UIScrollerView滚动方向判断
- UIScrollerView滚动方向判断
- UIScrollerView滚动方向判断
- Xib 约束 UIScrollerView
- UIScrollerView的简单使用
- UIScrollerView的scrollRectToVisible方法
- 【转】ListView 中使用onItemClick和onItemLongClick
- 查看ubuntu版本、位数、内核版本
- mysql设置不区分大小写
- 0 0/1 * * * ?
- tomcat启动内存溢出解决方法
- UIScrollerView基础
- xshell如何使用ssh连接远程
- Autolayout示例2-Masonry实现
- Xshell使用教程及WinSCP使用教程
- AFNetWorking 监听网络连接的状态
- datetimepicker-bootstrap默认年份1899修改问题
- linux下使用swig让python调用C++(复杂版:包括多文件调用和链接库)
- 什么是实时应用程序自我保护(RASP)?
- HibernateException: Could not obtain transaction-synchronized Session for current thread