UIRefreshControl是iOS6自带的UITableView下拉刷新控件。
- (instancetype)init;
@property (nonatomic, readonly, getter=isRefreshing) BOOL refreshing;
@property (null_resettable, nonatomic, strong) UIColor *tintColor;
@property (nullable, nonatomic, strong) NSAttributedString *attributedTitle UI_APPEARANCE_SELECTOR;
// May be used to indicate to the refreshControl that an external event has initiated the refresh action
- (void)beginRefreshing NS_AVAILABLE_IOS(6_0);
// Must be explicitly called when the refreshing has completed - (void)endRefreshing NS_AVAILABLE_IOS(6_0);
// UITableView
_tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
[self.view addSubview:_tableView];
// UIRefreshControl
_refreshControl = [[UIRefreshControl alloc] init];
_refreshControl.tintColor = [UIColor redColor];
_refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"下拉刷新"];
[_refreshControl addTarget:self action:@selector(refreshControlAction) forControlEvents:UIControlEventValueChanged];
[_tableView addSubview:_refreshControl];
网友评论