zoukankan      html  css  js  c++  java
  • iOS 下拉刷新 上拉加载实现原理

    1、下拉刷新 实现原理

    if (scrollView.contentOffset.y < -100) {
    
        
    
        [UIView animateWithDuration:1.0 animations:^{
    
        
    
            self.scrollView.contentInset = UIEdgeInsetsMake(100, 0, 0, 0);
    
            
    
        } completion:^(BOOL finished) {
    
        
    
            NSLog(@"发起下拉刷新");
    
            
    
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    
                
    
                [UIView animateWithDuration:1.0 animations:^{
    
                    
    
                    self.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    
    
                }];
    
                
    
            });
    
            
    
        }];
    
    
    
    }
    

    2、上拉加载 实现原理

    if (scrollView.bounds.size.height +  scrollView.contentOffset.y >scrollView.contentSize.height) {
    
        
    
        [UIView animateWithDuration:1.0 animations:^{
    
            
    
            self.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);
    
            
    
        } completion:^(BOOL finished) {
    
            
    
            NSLog(@"发起上拉加载");
    
            
    
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    
                
    
                [UIView animateWithDuration:1.0 animations:^{
    
                    
    
                    self.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
                    
    
                }];
    
            });
    
        }];
    
        
    
        
    
    }
  • 相关阅读:
    学习进度表 06
    课堂练习第七周
    学习进度表 05
    学习进度表 04
    分组情况
    求子数组最大值
    codeforce 8A-8C
    nginx 设置服务,开机启动
    转 ubuntu 安装php
    Nginx小记
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5313671.html
Copyright © 2011-2022 走看看