01-UIScrollView01-大图片展示
- //
- // 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
作者:
出处:http://www.cnblogs.com/ChenYilong/(点击RSS订阅)
本文版权归作者和博客园共有,欢迎转载,
但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。