zoukankan      html  css  js  c++  java
  • iOS开发——缩放图片

      捏合图片,在原imageView中放大缩小图片。

      懒得多说,直接上代码:

    //

    //  ViewController.m

    //  Demo-hehehe

    //

    //  Created by yyt on 16/4/25.

    //  Copyright © 2016年 yyt. All rights reserved.

    //

    #import "ViewController.h"

    @interface ViewController ()<UIScrollViewDelegate>{

        UIImageView *imageView;

    }

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(20, 80, self.view.bounds.size.width-40, 300)];

        scrollview.delegate=self;

        scrollview.maximumZoomScale=5.0;

        scrollview.minimumZoomScale=0.5;

        [self.view addSubview:scrollview];

        

        imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 80, self.view.bounds.size.width-40, 300)];

        imageView.image =[UIImage imageNamed:@"22"];

        imageView.userInteractionEnabled = YES;

        [scrollview addSubview:imageView];

    }

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

        return imageView;

    }

    @end

  • 相关阅读:
    11.22
    python之字典(dict)
    Version Control
    java_实现一个类只能声明一个对象
    javase-位运算符
    javase-整数变量的交换
    URI和URL的关系与区别
    http解析
    函数式语言
    MyIASM和Innodb引擎详解
  • 原文地址:https://www.cnblogs.com/yyt-hehe-yyt/p/5431506.html
Copyright © 2011-2022 走看看