//
// UIDemoViewController.m
// 06-1UIScrollDemo
//
// Created by k on 14-9-4.
// Copyright (c) 2014年 com.akleee.www. All rights reserved.
//
#import "UIDemoViewController.h"
@interface UIDemoViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollViw;
@property (weak, nonatomic) IBOutlet UIImageView *img;
- (IBAction)changeOffset:(id)sender;
@end
@implementation UIDemoViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//NSLog(@"%@",NSStringFromCGRect(_img.frame));
//设置可移动区域
_scrollViw.contentSize=_img.bounds.size;
//可视窗口位置
int moveTop=,moveLeft=;
_scrollViw.contentOffset=CGPointMake(moveTop, moveLeft);
//可视窗口大小
//int windowW=100,windowH=400,windowX=10,windowY=20;
// _scrollViw.frame=CGRectMake(windowX, windowY, windowW, windowH);
//外边距
int paddingT=,paddingL=,paddingR=,paddingB=;
_scrollViw.contentInset=UIEdgeInsetsMake(paddingT, paddingL, paddingB, paddingR);
//水平滚动条
// _scrollViw.showsHorizontalScrollIndicator=NO;
//
// //垂直滚动条
// _scrollViw.showsVerticalScrollIndicator=NO;
_scrollViw.delegate=self;
_scrollViw.maximumZoomScale=;
_scrollViw.minimumZoomScale=0.1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
//开始拖拽
//NSLog(@"scrollViewWillBeginDragging %@",NSStringFromCGPoint(scrollView.contentOffset));
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
//正在拖拽
//NSLog(@"scrollViewDidScroll %@",NSStringFromCGPoint(scrollView.contentOffset));
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
//拖拽结束
//NSLog(@"scrollViewDidEndDragging %@",NSStringFromCGPoint(scrollView.contentOffset));
}
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
//拖动后开始滑行
//NSLog(@"scrollViewWillBeginDecelerating %@",NSStringFromCGPoint(scrollView.contentOffset));
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
//拖动后滑行结束
//NSLog(@"scrollViewDidEndDecelerating %@",NSStringFromCGPoint(scrollView.contentOffset));
}
-(void)scrollViewDidScrollToTop:(UIScrollView *)scrollView{
//滑动到下方内容 点击系统顶部导航 自动定位到顶部时触发
//NSLog(@"scrollViewDidScrollToTop %@",NSStringFromCGPoint(scrollView.contentOffset));
}
-(BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView{
//滑动到下方内容 点击系统顶部导航
NSLog(@"scrollViewShouldScrollToTop %@",NSStringFromCGPoint(scrollView.contentOffset));
//返回是否 自动定位到顶部
return NO;
}
-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView{
// 当触发[_scrollViw setContentOffset:CGPointMake(200, 200) animated:YES];后 触发此事件
//如果animated:NO的话 不会触发此事件
//NSLog(@"scrollViewDidEndScrollingAnimation %@",NSStringFromCGPoint(scrollView.contentOffset));
}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
//设置需要缩放的UIView
// NSLog(@"viewForZoomingInScrollView %@",NSStringFromCGPoint(scrollView.contentOffset));
return _img;
}
-(void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view{
//开始缩放
NSLog(@"scrollViewWillBeginZooming");
}
-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{
//结束缩放
NSLog(@"scrollViewDidEndZooming");
}
- (IBAction)changeOffset:(id)sender {
NSLog(@"change offset");
[_scrollViw setContentOffset:CGPointMake(, ) animated:NO];
//_scrollViw .contentOffset=CGPointMake(200, 200);
}
@end