码迷,mamicode.com
首页 > 其他好文 > 详细

UIScrollView

时间:2014-11-19 01:21:03      阅读:152      评论:0      收藏:0      [点我收藏+]

标签: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

标签:uiscrollview   控件   

原文地址:http://blog.csdn.net/huanghaiyan_123/article/details/41256179

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!