//
// 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