UIRefreshControl 颜色问题

4

各位Stackoverflow网友们!

我再一次来到这里向各位聪明的大脑求助。这次遇到了一个非常奇怪的问题,可惜的是,我无法理解它。

这个问题与使用UIRefreshControl进行下拉刷新有关。当通过下拉手势触发下拉刷新时,它本身是正常工作的。但是当我手动触发加载时,虽然可以正常工作,但出现一个阻碍性问题-活动指示器的颜色不会更改为所设置的色调颜色。

-viewDidLoad

    _publicationsRefreshControl = [[UIRefreshControl alloc] init];
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(localizationRefreshControlTitle, nil) attributes:@{NSFontAttributeName : [UIFont fontWithName:fontLatoRegular size:14], NSForegroundColorAttributeName : [UIColor whiteColor]}];
_publicationsRefreshControl.attributedTitle = attributedTitle;
_publicationsRefreshControl.tintColor = [UIColor whiteColor];
[_publicationsRefreshControl addTarget:self action:@selector(refreshPublications:) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:_publicationsRefreshControl];

这个方法可以正确初始化UIRefreshControl,当你下拉CollectionView时确实会起作用。
当我使用以下方法:
- (void)action {
[_publicationsRefreshControl beginRefreshing];
[_collectionView setContentOffset:CGPointMake(0, _collectionView.contentOffset.y - _publicationsRefreshControl.frame.size.height) animated:YES];
[_publicationsRefreshControl sendActionsForControlEvents:UIControlEventValueChanged]; }

如果手动开始刷新,活动指示器的颜色不会变为白色,而是保持默认颜色。我已尝试在操作方法中设置tintColor属性,并尝试了所有可能的放置组合,但都没有成功。

有趣的是,如果我先下拉集合视图并开始刷新,然后再尝试手动开始刷新,则它将正确地显示为白色。只有当我尝试首先手动刷新时才会出现颜色问题。

我尝试过的其他选项:

  1. 尝试调用tintColorDidChange
  2. 尝试手动更改底层ActivityIndicatorView的样式

感谢任何人愿意提供帮助 :)


你已经让它工作了吗? - va05
我恐怕没有。我只是在手动刷新时不显示刷新控件。 - D6mi
1个回答

1

尝试:

[_myRefreshControl endRefreshing];
_myRefreshControl.tintColor = [UIColor whiteColor];

对我有用!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接