zoukankan      html  css  js  c++  java
  • UIScrollView


    #import "QYViewController.h"


    @interface QYViewController ()<UIScrollViewDelegate>

    {

        UIImageView *_imageView;

    }

    @end


    @implementation QYViewController


    - (void)viewDidLoad

    {

        [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

        //1.加入UIScrollerView

        UIScrollView *scrollView = [[UIScrollView alloc]init];

        scrollView.frame = self.view.bounds;

        //scrollView加入到视图

        [self.view addSubview:scrollView];

        //2.加入图片

        UIImage *image = [UIImage imageNamed:@"4"];

        _imageView = [[UIImageView alloc]initWithImage:image];

        

        //设置代理

        scrollView.delegate = self;

        //设置最小伸缩比例

        scrollView.minimumZoomScale = 0.2;

        //设置最大伸缩比例

        scrollView.maximumZoomScale = 2.0;

        

        //3.设置内容范围

        scrollView.contentSize = image.size;

        //_imageView加入到scrollView视图

        [scrollView addSubview:_imageView];

        

    }

    #pragma mark - 这种方法返回的控件就能进行捏合手势缩放操作

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

    {

        return _imageView;

    }


  • 相关阅读:
    兼容python3 小烦
    fstring 和 海象赋值
    Go-gRPC的简单使用
    GO-操作etcd简单示例
    进度报告
    进度报告
    windown 10 安装redis
    在.Net Core中使用T4工具生成实体文件
    python-with关键字,json,pickie序列化与反序列化
    python-文件操作-读,写,追加
  • 原文地址:https://www.cnblogs.com/clnchanpin/p/6809992.html
Copyright © 2011-2022 走看看