IOS大图片处理(附源码)

  • 大图片处理
ViewController.m
--------------------------------------------------
(void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //大图片滑动
    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);//设置UIScrollView的可视范围
    scrollView.backgroundColor = [UIColor grayColor];//设置UIScrollView背景颜色为灰色
    [self.view addSubview:scrollView];//加载UIScrollView

    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"xingkong.jpg"];
    CGFloat imgW = imageView.image.size.width;//图片的宽度
    CGFloat imgH = imageView.image.size.height;//图片的高度
    imageView.frame = CGRectMake(0, 0, imgW, imgH);
    [scrollView addSubview:imageView];

    //设置UIScrollView的滚动范围(内容大小)
    scrollView.contentSize = imageView.image.size;
}-

Demo

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。