为 UIRefreshControl 提供顶部插图

Give a top inset to UIRefreshControl(为 UIRefreshControl 提供顶部插图)

本文介绍了为 UIRefreshControl 提供顶部插图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用类似的 UIRefreshControl(没有 UITableViewController):

I use an UIRefreshControl like it (without an UITableViewController) :

UIRefreshControl *refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:@selector(viewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged];
[self.table addSubview:refreshControl];

问题是刷新轮位于 UINavigationController 的半透明栏下方 (ios7).StackOverflow 上关于这个问题的话题很少.而且他们没有给我带来任何有价值的解决方案.

Problem is the refresh wheel is positioned below the UINavigationController's translucent bar (ios7). There is only a few topic on this problem on StackOverflow. And they didn't bring any valuable solution to me.

例如,我希望将 UIRefreshControl 的 y 位置向下 80px.

What I wish is to make my UIRefreshControl's y position 80px down for example.

注意:我知道不建议在 UITableViewController 之外使用 UIRefreshControl.所以不需要警告它.

Note : I know it's not recommended to use UIRefreshControl outside an UITableViewController. So no need to warn about it.

推荐答案

我找到了一个解决方案,非常简单,不是很干净,但效果很好.

I found a solution, very simple, not so clean but works like a charm.

只需要将刷新控件放在另一个设置的子视图中即可.

Just need to put the refresh control in another subview which is set down.

UIView *refreshView = [[UIView alloc] initWithFrame:CGRectMake(0, 80, 0, 0)];
[self.table addSubview:refreshView];

UIRefreshControl *refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:@selector(viewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged];
[refreshView addSubview:refreshControl];

这篇关于为 UIRefreshControl 提供顶部插图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:为 UIRefreshControl 提供顶部插图

基础教程推荐