美文网首页iOS 开发
UIScrollView 缩放

UIScrollView 缩放

作者: 挖掘机 | 来源:发表于2016-02-17 09:56 被阅读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


相关文章

网友评论

    本文标题:UIScrollView 缩放

    本文链接:https://www.haomeiwen.com/subject/bzfmkttx.html