UIScrollView 缩放
2016-02-17 本文已影响137人
挖掘机
UIScrollView 缩放
#import "ViewController.h"
@interface ViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property(nonatomic,weak)UIImageView * imageView ;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"minion"]];
[self.scrollView addSubview:imageView];
self.imageView=imageView;
self.scrollView.backgroundColor=[UIColor redColor];
self.scrollView.contentSize=imageView.image.size;
self.scrollView.delegate=self;
self.scrollView.maximumZoomScale=3.5;
self.scrollView.minimumZoomScale=4.5;
}
-(UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.imageView;
}
-(void)scrollViewDidZoom:(UIScrollView *)scrollView
{
NSLog(@"缩放ing----%f",scrollView.zoomScale);
}
@end