您的位置:首页 > 移动开发 > IOS开发

iOS开发——缩放图片

2016-04-25 16:42 363 查看
  捏合图片,在原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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: