UIRefreshControl的色调错误

时间:2018-05-23 08:29:12

标签: ios objective-c uirefreshcontrol tintcolor

我在UITableViewController中使用UIRefreshControl来刷新内容。我在-viewDidLoad方法中使用以下代码将其添加到我的表中。

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

//[refresh setAttributedTitle:[[NSAttributedString alloc] initWithString:@"Reloading" attributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor]}]];

[refresh setTintAdjustmentMode:UIViewTintAdjustmentModeNormal];
[refresh setTintColor:[UIColor colorFromHex:0xff8900]];
[refresh addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];

[[refresh layer] setZPosition:-1.0f];

//if (iOS_AT_LEAST(10)) {
//  [self setRefreshControl:refresh];
//} else {
    [self setRefresher:refresh];
    [[self tableView] insertSubview:[self refresher] atIndex:0];
//}

我为UIColor创建了一个类别,因此它可以接受十六进制值。我在完整的应用程序中使用它,在另一个位置我得到#ff8900,这是正确的。但是在UIRefreshControl上设置色调颜色会给我#fb6a2e这是奇怪的。当我尝试默认颜色时会发生同样的情况,例如[UIColor lightGrayColor]给我另一种色彩,而不是给另一个视图提供相同的颜色。

我找到了以下帖子:UIRefreshControl tint color doesn't match given color。我试着将它放入一个动画块和答案中给出的黑客,但没有运气。

我在这里做错了什么?

另一个问题。设置属性标题时,微调器从顶部开始有更大的空间。如果发生这种情况,如果只有一个可用,则标题将位于单元格下方。有没有办法移动字符串?

enter image description here

0 个答案:

没有答案
相关问题