uitableView 自帶的刷新控件

uitableView 自帶刷新控件,只需幾行代碼輕鬆搞定上拉刷新

   UIRefreshControl * refresh = [[UIRefreshControl alloc]init];   

   NSAttributedString * title = [[NSAttributedString alloc]initWithString:@"刷新"];

    refresh.attributedTitle = title;

    refresh.tintColor = [UIColor grayColor];

    self.refresh = refresh;

    [refresh addTarget:self action:@selector(refreshAction) forControlEvents:(UIControlEventValueChanged)];

    [tableView addSubview:refresh];



#pragma mark - 刷新

- (void)refreshAction{

    NSAttributedString * title = [[NSAttributedString alloc]initWithString:@"加載。。。。"];

    self.refresh.attributedTitle = title;

     //刷新
    [self performSelector:@selector(myBrokeFinishRefresh) withObject:nil afterDelay:2.0];

}


- (void)myBrokeFinishRefresh{
    [currentRefreshCrtl endRefreshing];
    NSAttributedString * refreshCtrl = [[NSAttributedString alloc]initWithString:@"下拉刷新"];
    currentRefreshCrtl.attributedTitle = refreshCtrl;
    
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章