UIRefreshControl incorrect title offset during first run and sometimes title missing

前端 未结 8 971
自闭症患者
自闭症患者 2020-12-04 15:46

The text is offset wrong by the first launch of UIRefreshControl... later sometimes the refresh text doesn\'t show up at all and just the spiny is visible

I don\'t t

8条回答
  •  被撕碎了的回忆
    2020-12-04 16:15

    I had the same problem and for me it worked with layoutIfNeeded after setting the attributedTitle:

    - (void)setRefreshControlText:(NSString *)text
    {
        UIColor *fg = [UIColor colorWithWhite:0.4 alpha:1.0];
        NSDictionary *attrsDictionary = @{NSForegroundColorAttributeName: fg};
        self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:text attributes:attrsDictionary];
        [self.refreshControl layoutIfNeeded];
    }
    

    Cédric suggested to use [self.refreshControl setNeedsLayout], but this does not force an immediate update of the view, so you must use layoutIfNeeded.

提交回复
热议问题