刷新视图背景颜色

aai*_*aev 1 uitableview ios swift

我正在refreshcontroltableview这种方式添加,但视图的背景颜色是白色。我怎样才能将其设置为默认值?谢谢。

var refreshControl:UIRefreshControl!
refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
tableView.addSubview(refreshControl)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

UPD:它也不能顺利工作。

Ste*_*han 5

如果您的代码在 UITableviewController 中,则不必添加子视图。UITableViewControllers 有一个refreshControl属性,所以你可以设置

self.refreshControl = UIRefreshControl()
Run Code Online (Sandbox Code Playgroud)

如果你这样做了,背景颜色应该与你的 tableView 的背景颜色相同。如果你想要不同的颜色,你可以使用

self.refreshControl.backgroundColor = UIColor.yourColor()
Run Code Online (Sandbox Code Playgroud)