码迷,mamicode.com
首页 > 移动开发 > 详细

[iOS基础控件 - 5.2] 查看大图、缩放图片代码(UIScrollView制作)

时间:2014-11-29 06:42:31      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

原图: 900 x 1305
 bubuko.com,布布扣  bubuko.com,布布扣
 
拖曳滚动:
bubuko.com,布布扣
 
缩放:
bubuko.com,布布扣      bubuko.com,布布扣
 
 
主要代码:
 1 //
 2 //  ViewController.m
 3 //  ImageZoom
 4 //
 5 //  Created by hellovoidworld on 14/11/28.
 6 //  Copyright (c) 2014年 hellovoidworld. All rights reserved.
 7 //
 8 
 9 #import "ViewController.h"
10 
11 @interface ViewController ()
12 
13 // 图片控件
14 @property (weak, nonatomic) IBOutlet UIImageView *imageView;
15 
16 // UIScrollView控件
17 @property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
18 
19 @end
20 
21 @implementation ViewController
22 
23 - (void)viewDidLoad {
24     [super viewDidLoad];
25     // Do any additional setup after loading the view, typically from a nib.
26    
27     self.scrollView.contentSize = CGSizeMake(900, 1305);
28     self.scrollView.delegate = self;
29    
30     self.scrollView.maximumZoomScale = 2.0;
31     self.scrollView.minimumZoomScale = 0.1;
32    
33 }
34 
35 - (void)didReceiveMemoryWarning {
36     [super didReceiveMemoryWarning];
37     // Dispose of any resources that can be recreated.
38 }
39 
40 
41 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
42      NSLog(@"开始拖曳");
43 }
44 
45 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
46     NSLog(@"正在拖曳");
47 }
48 
49 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
50     NSLog(@"结束拖曳");
51 }
52 
53 
54 // 缩放手势调用的方法
55 - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
56     return self.imageView; // 需要放大的ImageView
57 }
58 
59 - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view {
60     NSLog(@"开始缩放");
61 }
62 
63 - (void)scrollViewDidZoom:(UIScrollView *)scrollView {
64     NSLog(@"正在缩放");
65 }
66 
67 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale {
68     NSLog(@"结束缩放");
69 }
70 
71 - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
72     NSLog(@"拖曳完成后减速开始");
73 }
74 
75 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
76     NSLog(@"拖曳完成后减速完成");
77 }
78  
79 @end
80  

 

[iOS基础控件 - 5.2] 查看大图、缩放图片代码(UIScrollView制作)

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/hellovoidworld/p/4129819.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!