• 缩放子控件


     
     

    #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

     
     
  • 相关阅读:
    webpack
    localStorage使用总结
    html5 的localstorage
    js 的登录验证
    webpack vue2.0项目脚手架生成的webpack文件
    vue2.0 keep-alive最佳实践
    npm 的指令介绍
    vue2.0 子组件和父组件之间的传值
    electron的通信
    electron 的窗口设置最大化 最小化
  • 原文地址:https://www.cnblogs.com/GhostKZShadow/p/5105499.html
Copyright © 2020-2023  润新知