zoukankan      html  css  js  c++  java
  • 缩放子控件

     
     

    #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

     
     
  • 相关阅读:
    tmp
    GO语言中使用OpenCV
    The OpenCV Coding Style Guide
    下载tree命令的源代码
    convention over configuration 约定优于配置 按约定编程 约定大于配置 PEP 20 -- The Zen of Python
    tmp
    起步依赖
    Spring Boot Dubbo Dubbok spring cloud
    pug.compile() will compile the Pug source code into a JavaScript function that takes a data object (called “locals”) as an argument.
    request /a?b= /a/?b=
  • 原文地址:https://www.cnblogs.com/GhostKZShadow/p/5105499.html
Copyright © 2011-2022 走看看