zoukankan      html  css  js  c++  java
  • 简单的UIScrollView 下拉刷新

    这里只贴主要代码

    #import "ViewController.h"
    @interface ViewController ()<UIScrollViewDelegate>{
        UIView * _loadView;
    }
    
    - (void)viewDidLoad {
        _loadView = [[UIView alloc] initWithFrame:CGRectMake(0,  -44, 320, 44)];
        //...
    }
    
    #pragam mark UIScrollView Delegate
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        _loadView.frame = CGRectMake(0, -44 - scrollView.contentOffset.y, 320, 44);
        if (scrollView.contentOffset.y<= -44) {
            //处理松开刷新提示
        }  else {
            //关闭松开刷新提示
        }
    }
    
    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
        if (scrollView.contentOffset.y<= -44) {
            //此处动画纯粹为了过度平滑
            [UIView animateWithDuration:0.2 animations:^(void) {
                 scrollView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0);
             }completion:^(BOOL complete) {
                 //处理需要加载的东西
            }];
        }
    }
    
    //...
    转载请注明出处:http://duwei.cnblogs.com/
  • 相关阅读:
    刘汝佳,竖式问题
    二叉树
    sort
    hash
    贪心算法
    FFT,NTT 专题
    hdu 5861 Road 两棵线段树
    hdu 5862 Counting Intersections
    hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法
    hdu 5800 To My Girlfriend + dp
  • 原文地址:https://www.cnblogs.com/duwei/p/5150477.html
Copyright © 2011-2022 走看看