scrollView 的简单 属性 以及 使用
//--------------------------------------------------------------------------------
RoootViewController.h
//--------------------------------------------------------------------------------
#import <UIKit/UIKit.h>
@interface RoootViewController : UIViewController
//定义UIScrollViewui 变量
@property (strong,nonatomic)UIScrollView *scrollview;
@end
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
@interface RoootViewController ()
@end
@implementation RoootViewController
- (void)dealloc
{
[_scrollview release];
[super dealloc];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor greenColor];
[self createScrollview ];
// Do any additional setup after loading the view.
}
-(void)createScrollview
{_scrollview =[[UIScrollView alloc]initWithFrame:self.view.bounds];
_scrollview.backgroundColor=[UIColor orangeColor];
[self.view addSubview:_scrollview];
[self customScrollview];
}
-(void)customScrollview
{
UIImage *image=[UIImage imageNamed:@"car4.jpg"];
UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
imageView.image=image;
//image 用的 类方法 当我们这个函数结束的时候会自动的释放一次 如果吧图片加载上imagevie上
// imageview 会自动保留一次计数 image页 一起消失;[_scrollview addSubview:imageView];
//conentSize 来控制 滚动的范围
_scrollview.contentSize=image.size;
//设置超出边界 反弹效果 默认为yes
_scrollview .bounces=NO;//活动时候的水平和 垂直方向额滚动条默认 为 YES
_scrollview .showsHorizontalScrollIndicator=NO;
_scrollview.showsVerticalScrollIndicator=YES;
//设置滚动条样式
/*
UIScrollViewIndicatorStyleDefault, // black with white border. good against any background
UIScrollViewIndicatorStyleBlack, // black only. smaller. good against a white background
UIScrollViewIndicatorStyleWhite
*/
_scrollview .indicatorStyle=UIScrollViewIndicatorStyleWhite;
//设置视图的边距
_scrollview.contentInset=UIEdgeInsetsMake(0, 0, 150, 50);
//设置滚动条的 边距
_scrollview .scrollIndicatorInsets=UIEdgeInsetsMake(0, 0, 50, 50) ;
//控制翻页 他滑动的是 滚动视图的宽度和高度
_scrollview.pagingEnabled=YES;
//禁止滚动
//_scrollview.scrollEnabled=NO;
//滚动的速度
_scrollview.decelerationRate=1;
//偏移量
_scrollview.contentOffset=CGPointZero;
//最da缩放系数
_scrollview.maximumZoomScale=2;
//最小缩放系数
_scrollview.minimumZoomScale=0.2;
//缩放参数
_scrollview.zoomScale=3;
[image release];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//--------------------------------------------------------------------------------