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
网友评论