捏合图片,在原imageView中放大缩小图片。
懒得多说,直接上代码:
//
// ViewController.m
// Demo-hehehe
//
// Created by yyt on 16/4/25.
// Copyright © 2016年 yyt. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()<UIScrollViewDelegate>{
UIImageView *imageView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(20, 80, self.view.bounds.size.width-40, 300)];
scrollview.delegate=self;
scrollview.maximumZoomScale=5.0;
scrollview.minimumZoomScale=0.5;
[self.view addSubview:scrollview];
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 80, self.view.bounds.size.width-40, 300)];
imageView.image =[UIImage imageNamed:@"22"];
imageView.userInteractionEnabled = YES;
[scrollview addSubview:imageView];
}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return imageView;
}
@end