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
懒得多说,直接上代码:
//
// 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
相关文章推荐
- audio 在ios上自动播放问题
- 【转载】iOS提示框,为什么你应该使用 MBProgressHUD?
- iOS-仿网易云音乐控制器
- iOS 邮箱、手机号、身份证....正则表达式
- iOS-仿百度卫士动画
- iOS 模态弹出 presentViewController弹出页面时有延迟
- iOS如何上传代码到Github
- iOS Core Animation
- IOS开源项目学习---oschina
- iOS代码对齐 ---XAlign
- iOS屏幕旋转 浅析
- IOS中延时执行的几种方式的比较和汇总
- IOS开发之----使用ZipArchive解压缩文件
- NSNotification-iOS初学
- iOS每日一记之-------------------获取label的行数。。。。。恩
- 关于iOS定位问题
- iOS开发用boundingRectWithSize:options:attributes:context:写的一个分类
- iOS 常用知识总结
- [iOS]FDFullscreenPopGesture 全局返回手势 与 pan手势冲突
- Attributes-iOS初学