1

I am using a UIRefreshControl in my UITableViewController to refresh the content. I use the following code in my -viewDidLoad method to add it to my table.

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];
//}

I created a category for UIColor so it can accept hex values. I use this in the complete application and on another location I get #ff8900 back which is correct. But setting the tint color on the UIRefreshControl gives me #fb6a2e which is odd. The same happens when I try a default color, for example [UIColor lightGrayColor] gives me another tint than giving the same color to another view.

I have found the following post: UIRefreshControl tint color doesn't match given color. I tried to put it into an animation block and the hack given in the answer, but with no luck.

What do I do wrong here?

Another side question. When setting the attributed title, the spinner has a greater space from the top. If this happens, the title will be below the cell if only one is available. Is there a way to move the string up?

enter image description here

Kazunori Takaishi
  • 2,268
  • 1
  • 15
  • 27
Sietse
  • 623
  • 1
  • 8
  • 23
  • This is *really* strange. Did you try adding a View.LayoutIfNeeded(); after all that to make sure the drawing cycle has taken every change into account? – Gil Sand May 23 '18 at 11:04
  • Thanks for the reply. I haven't, but I just tested it without any luck. I also saw another strange thing happens when I don't stop the spinner, push another viewcontroller on top of the current one and go back and in the ```-viewWillAppear:``` method states the spinner has to begin spinning again, the color fades from black to the color. I don't set the color in this method anymore, so it already should be orange. – Sietse May 24 '18 at 09:04

0 Answers0