标签:uiscrollview 控件
#import "QYViewController.h"
@interface QYViewController ()<UIScrollViewDelegate>
{
UIImageView *_imageView;
}
@end
@implementation QYViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//1.添加UIScrollerView
UIScrollView *scrollView = [[UIScrollView alloc]init];
scrollView.frame = self.view.bounds;
//把scrollView添加到视图
[self.view addSubview:scrollView];
//2.添加图片
UIImage *image = [UIImage imageNamed:@"4"];
_imageView = [[UIImageView alloc]initWithImage:image];
//设置代理
scrollView.delegate = self;
//设置最小伸缩比例
scrollView.minimumZoomScale = 0.2;
//设置最大伸缩比例
scrollView.maximumZoomScale = 2.0;
//3.设置内容范围
scrollView.contentSize = image.size;
//将_imageView添加到scrollView视图
[scrollView addSubview:_imageView];
}
#pragma mark - 这个方法返回的控件就能进行捏合手势缩放操作
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return _imageView;
}
标签:uiscrollview 控件
原文地址:http://blog.csdn.net/huanghaiyan_123/article/details/41256179