UIScrollView、UIPageControl、NSTimer

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值