zoukankan      html  css  js  c++  java
  • IOS TableView的下拉刷新与小菊花样本

    //_tableView 这个太简单需要的代码篇幅有点多,自己去定义,
    //
    设置全局变量 UIRefreshControl* refres; //下拉刷新 refres=[[UIRefreshControl alloc]init]; refres.attributedTitle=[[NSAttributedString alloc]initWithString:@"下拉刷新中..."]; [refres addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged]; [_tableView addSubview:refres];
    //上面的代码添加在ViewDidLoad中
    //下拉所要触发的事件,刷新逻辑可以写在里面 -(void)refresh{ NSLog(@"刷新修改表"); if (refres.refreshing) { refres.attributedTitle=[[NSAttributedString alloc]initWithString:@"刷新成功"]; [refres endRefreshing]; } }

     小菊花控件

    #import <UIKit/UIKit.h>
    
    @interface ActivityViewAction : UIView
    {
        UIActivityIndicatorView * _activityV;
        UILabel * _textLabel;
    }
    
    //显示文本和小菊花.
    -(void)showWithText:(NSString *)showText;
    
    
    -(void)hidden;
    
    @end
    
    
    
    #import "ActivityViewAction.h"
    
    @implementation ActivityViewAction
    
    
    -(instancetype)initWithFrame:(CGRect)frame
    {
        if (self = [super initWithFrame:frame])
        {
            //        背景View  为了防止,用户误操作.
            UIView * backgroundView = [[UIView alloc] initWithFrame:self.bounds];
            backgroundView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
             
            
            [self addSubview:backgroundView];
            
            UIView * loadingV = [[UIView alloc] initWithFrame:CGRectMake(120, 300, 100, 100)];
            
            loadingV.layer.cornerRadius = 10;
            
            loadingV.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
            
            [self addSubview:loadingV];
            //      小菊花  (考究:它的宽高是多少.37,37)
            _activityV = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
            _activityV.color=[UIColor blackColor];
            _activityV.center = CGPointMake(50, 40);
            
            [loadingV addSubview:_activityV];
            
            
            _textLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 65, 80, 30)];//小菊花下面的文本
            _textLabel.textColor = [UIColor blackColor];
            _textLabel.textAlignment= NSTextAlignmentCenter;
            [loadingV addSubview:_textLabel];
            self.alpha=0;
        }
        return self;
    }
    //显示调用这个函数
    -(void)showWithText:(NSString *)showText
    {
        if (self.alpha == 0)//包含了,self.hidden == YES
        {
            self.alpha = 1.0;
            _textLabel.text = showText;
            [_activityV startAnimating];
        }
    }
    //隐藏调用这个函数
    -(void)hidden
    {
        self.alpha = 0.0;
        [_activityV stopAnimating];
        _textLabel.text = @"";
    }

    这个只是大体的样本,具体需求自己添加

  • 相关阅读:
    《基于玩家分享行为的手游传播模式研究》
    并行多核体系结构基础——第四章知识点和课后习题
    numpy中的nan和常用方法
    《基于多层复杂网络的传播行为建模与分析》
    《基于SD-SEIR模型的实验室人员不安全行为传播研究》
    《基于SIR的路边违停行为传播模型研究》
    《基于SIRS模型的行人过街违章传播研究》
    阿里巴巴编码规范-考试认证
    测试菜鸟!!当领导我问:“测得怎么样了?”我慌到一P
    国内软件测试过度吹捧自动化测试,然而在国外是这样子的
  • 原文地址:https://www.cnblogs.com/mojiewei/p/5047529.html
Copyright © 2011-2022 走看看