码迷,mamicode.com
首页 > 其他好文 > 详细

缩放子控件

时间:2016-01-06 15:33:57      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

 
 技术分享

#import "ViewController.h"

 

@interfaceViewController ()<UIScrollViewDelegate>

 

@property (strongnonatomicUIImageView *imageView;

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [superviewDidLoad];

    

    UIScrollView *scrolView = [[UIScrollViewalloc]initWithFrame:self.view.bounds];

    

    // 要实现缩放,就必须告诉scrollView的代理我要缩放哪个子控件(只能缩放内部的子控件)

    

    

    scrolView.delegate = self;

    

    scrolView.minimumZoomScale = 0.5;

    scrolView.maximumZoomScale = 2;

    

    // 内部自动调用

//    [self viewForZoomingInScrollView:scrolView];

    

    // imageViewsize默认就是图片的大小

    UIImageView *imageView = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"0.jpeg"]];

    self.imageView = imageView;

    

    scrolView.contentSize = CGSizeMake(imageView.bounds.size.width,imageView.bounds.size.height);

    

    [scrolView addSubview:imageView];

    [self.viewaddSubview:scrolView];

}

 

 

 

-(UIImageView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

    returnself.imageView;

}

 

 

// 正在缩放时调用,一直调用(无数次)

-(void)scrollViewDidZoom:(UIScrollView *)scrollView

{

//    NSLog(@"scrollViewDidZoom------");

}

 

 

// 缩放完毕调一次

-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale

{

//    NSLog(@"scrollViewDidEndZooming-%@--%f---",view,scale);

}

 

// 每次拖动调用一次

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

{

    NSLog(@"scrollViewWillBeginDragging----");

}

 

@end

 

 
 

缩放子控件

标签:

原文地址:http://www.cnblogs.com/GhostKZShadow/p/5105499.html

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