- 大图片处理
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;
}-
时间: 2024-10-13 11:33:27