博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UIScrollerView 的简单使用
阅读量:7080 次
发布时间:2019-06-28

本文共 1947 字,大约阅读时间需要 6 分钟。

 

 

//

//  RootViewController.m

//  Lianxi_02

//

//  Created by Super man on 15-2-11.

//  Copyright (c) 2015年 super man. All rights reserved.

//

 

#import "RootViewController.h"

 

@interface RootViewController ()<UIScrollViewDelegate>

{

    UIScrollView *_scrollView;

    UIImageView *_image;

    

}

@end

 

@implementation RootViewController

 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    _scrollView=[[UIScrollView alloc]initWithFrame:self.view.bounds];

    [self.view addSubview:_scrollView];

    

    _image=[[UIImageView alloc]init];

    _image.image=[UIImage imageNamed:@"meinv"];

    CGFloat imageW=_image.image.size.width;

    CGFloat imageH=_image.image.size.height;

    _image.frame=CGRectMake(0.0, 0.0, imageW, imageH);

    

    [_scrollView addSubview:_image];

    //滚动视图的尺寸

    _scrollView.contentSize=_image.image.size;

    //隐藏水平、垂直滚动条

    _scrollView.showsHorizontalScrollIndicator=NO;

    _scrollView.showsHorizontalScrollIndicator=NO;

    //增加额外的滚动区域(逆时针,上、左、下、右)

    _scrollView.contentInset=UIEdgeInsetsMake(20, 20, 20, 20);

    //最大比例

    _scrollView.maximumZoomScale=2.0;

    //最小比例

    _scrollView.minimumZoomScale=0.5;

    //实现委托

    _scrollView.delegate=self;

    

    

    // Do any additional setup after loading the view.

}

#define UIScrollViewDelegate

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

    

    return _image;

}

 

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

/*

 #pragma mark - Navigation

 

 // In a storyboard-based application, you will often want to do a little preparation before navigation

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

 {

 // Get the new view controller using [segue destinationViewController].

 // Pass the selected object to the new view controller.

 }

 */

 

@end

 

转载于:https://www.cnblogs.com/zhuzhushen/p/4286859.html

你可能感兴趣的文章
Leetcode: Arranging Coins
查看>>
简单学习node微信开发
查看>>
EditPlus如何设置保存时不产生.bak备份文件?
查看>>
用ISAPI Filter设置HttpOnly属性
查看>>
Zookeeper的安装部署,zookeeper参数配置说明,集群搭建,查看集群状态
查看>>
C++/Debug模式查看EFL(标志寄存器)详解
查看>>
我的友情链接
查看>>
oracle体系结构之 DB高速缓存池
查看>>
我的友情链接
查看>>
华为Agile Controller-Campus web界面admin管理员密码不对无法登陆
查看>>
遇到多个构造器参数时要考虑用构建器
查看>>
windos 8 虚拟光驱/硬盘技术
查看>>
WLC和汇聚交换机的配置
查看>>
使用python-gitlab的API V4来批量创建projects
查看>>
CLR.Via第三版第二章 生成、打包、部署和管理i应用程序及类型(
查看>>
我的系统我做主-----深度裁剪红帽5.8系统过程演示(只有5M哦)
查看>>
Zend server最大化应用程序的性能、扩展性和可用性
查看>>
Mac OSX操作系统安装和配置Zend Server 6教程(4)
查看>>
python进阶学习路线(全)
查看>>
浏览器加载与渲染
查看>>