Ios UIRefreshControl着色颜色不';与给定的颜色不匹配
刷新颜色与色调颜色不匹配,并且看起来不同,我尝试更改色调调整模式,但结果相同 请注意,微调器和文本颜色应为0x2C76BEIos UIRefreshControl着色颜色不';与给定的颜色不匹配,ios,uitableview,cocoa-touch,ios9,uirefreshcontrol,Ios,Uitableview,Cocoa Touch,Ios9,Uirefreshcontrol,刷新颜色与色调颜色不匹配,并且看起来不同,我尝试更改色调调整模式,但结果相同 请注意,微调器和文本颜色应为0x2C76BE tvc.refreshControl = [UIRefreshControl new]; tvc.refreshControl.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; tvc.refreshControl.tintColor = [UIColor colorWithHex:0x2C76BE]; tvc.ref
tvc.refreshControl = [UIRefreshControl new];
tvc.refreshControl.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
tvc.refreshControl.tintColor = [UIColor colorWithHex:0x2C76BE];
tvc.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to query spectrum again" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x2C76BE]}];
UIRefreshControl是一个有缺陷的类。我注意到放置
tvc.refreshControl.tintColor=[uicolorwithhex:0x2C76BE]动画块内的代码>将产生预期的结果(即使持续时间为零)。所以我测试了这个可怕的“黑客行为”:dispatch\u async(mainQueue,)代码>,这也给出了正确的结果。刷新控件也可能依赖于调用-beginRefreshing
或-endRefreshing
的时间
由于UIRefreshControl的缺陷和只能在UITableViewController中使用的限制让我非常恼火,因此我创建了一个完全可自定义的UIScrollView,可用于任何类型的UIScrollView(UICollectionView,UITableView)。请注意,我是在UICollectionViewFlowLayout支持像tableView一样的粘性标题之前创建的,因此当该选项处于启用状态时,我的refreshcontrol无法正常工作。请随时提交修复;)
您可以在这里找到它(如果这属于“无耻插拔条款”,我将删除此链接,但我认为它与问题有关。我遇到了类似的问题,UIRefreshControl在加载视图时没有正确显示颜色,我调用beginRefreshing()。如果用户拉刷新,控件将正确显示我指定的颜色
首先,对刷新控件进行子类化。然后,重写子类中的didMoveToWindow方法。下面的代码查找为创建微调器而设置动画的元素并设置其背景色
这段代码使用UIView的扩展返回视图的所有子视图(我使用了Jon Willis的答案)
微调器有一个CareReplicatorLayer,其视图包含一个子视图。该子视图只是一个矩形,用于实现微调器的图形元素。您正在着色的是该图形元素。0x2C76BE看起来不是十六进制颜色。没关系,它的#2C76BE=0x2C76BE这方面运气好吗?我遇到了同样的问题:(我遇到了同样的问题,我尝试了以下dispatch_async(dispatch_get_main_queue(),^(){[[self-refreshController]setTintColor:[uicolorfromhex:0xff8900]];);
并且颜色仍处于关闭状态。我自己没有调用-beginRefreshing
方法,而是由用户下拉表格。在动画块中设置色调颜色似乎也没有效果。
class CustomRefreshControl: UIRefreshControl {
override func didMoveToWindow() {
super.didMoveToWindow()
if let l = getNestedSubviews().first(where: { $0.layer is CAReplicatorLayer }), l.subviews.count > 0 {
l.subviews[0].backgroundColor = UIColor.orange //getNestedSubviews method is an extension of UIView as referenced above
}
}