- //
- // MJViewController.m
- // 01-UIScrollView01-大图片展示
- //
- // Created by apple on 13-11-27.
- // Copyright (c) 2013年 itcast. All rights reserved.
- //
- #import "MJViewController.h"
- @interface MJViewController ()
- @end
- @implementation MJViewController
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- UIScrollView *scrollView = [[UIScrollView alloc] init];
- scrollView.frame = CGRectMake(0, 0, 250, 250); // 指UIScrollView的可视范围
- scrollView.backgroundColor = [UIColor grayColor];
- [self.view addSubview:scrollView];
-
- UIImageView *imageView = [[UIImageView alloc] init];
- imageView.image = [UIImage imageNamed:@"big.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;
- // 隐藏水平滚动条
- scrollView.showsHorizontalScrollIndicator = NO;
- scrollView.showsVerticalScrollIndicator = NO;
-
- // 去掉弹簧效果
- // scrollView.bounces = NO;
-
- // top left bottom right
- scrollView.contentInset = UIEdgeInsetsMake(10, 20, 40, 80);
- }
- @end
https://www.evernote.com/shard/s227/sh/5e562326-d7af-4b51-8134-42fa544fd979/786f6301ad10be5c5ae80ba3bef5031a