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