UIScrollView、UIPageControl、NSTimer

来源:互联网 发布:淘宝互踩 编辑:程序博客网 时间:2024/05/24 06:02

UIScrollView

code

// 宽度为屏幕宽度9倍的UIScrollView

    UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame: self.view.frame];    myScrollView.backgroundColor = [UIColor lightGrayColor];    myScrollView.contentSize = CGSizeMake(self.view.frame.width * 9, 0);    [self.view addSubview: myScrollView];    [myScrollView release];

property

  • contentSize scrollView的内容size
  • contentOffset 偏移量(CGPoint)
  • pagingEnabled 按页滑动
  • bounces 边界回弹
  • showsHorizontalScrollIndicator 显示水平滚动条
  • maximumZoomScale 缩放比例
  • minimumZoomScale
  • alwaysBounceVertical 在没有垂直滚动范围时,边界回弹是否存在
  • scrollEnabled
  • scrollIndicatorInsets 滚动条的位置,造成用户假象
  • dragging 用户是否正在拖动
  • tracking 用户是否开始拖动.
  • decelerating 是否正在减速
  • srollsToTop 双击状态栏,是否回到最开始的位置
  • keyboardDismissMode 键盘消失模式

Method

setContentOffset:animated:

protocol

// 滑动结束- (void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView {}// 手拖拽结束- (void) scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {}

控制缩放

- (UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {    return [scrollView.subviews firstObject];}

UIPageControl

code

    UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 200, 200, 35)];    [self.view addSubview: myPageControl];    [myPageControl release];    myPageControl.numberOfPages = 7;    myPageControl.pageIndicatorTintColor = [UIColor yellowColor];    myPageControl.currentPageIndicatorTintColor = [UIColor redColor];    [myPageControl addTarget:self action:@selector(pageControlAction:) forControlEvents:UIControlEventValueChanged];

property

NSTimer

    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
0 0
原创粉丝点击