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);
    
                    
    
                }];
    
            });
    
        }];
    
        
    
        
    
    }
  • 相关阅读:
    原型模式
    哈希表原理
    Pow共识算法
    C++虚函数的工作原理
    TCP三次握手与四次分手
    TCP重置报文段及RST常见场景分析
    Ping、Traceroute工作原理
    ARP协议
    Rust生命周期bound用于泛型的引用
    Linux下core dump
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5313671.html
Copyright © 2011-2022 走看看