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);
    
                    
    
                }];
    
            });
    
        }];
    
        
    
        
    
    }
  • 相关阅读:
    QML的默认属性default property
    QtCreator下QML翻译
    QML开发常见错误(原)
    qt下的跨目录多工程编译(转)
    git使用笔记
    osgQt支持触摸屏
    Qt资源整理ING
    Visual assint x(转)
    C#开发重用方法
    UDP问题
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5313671.html
Copyright © 2011-2022 走看看