在UIRefreshControl
标题中使用多行文本是否可行?每当我在NSAttributedString
中添加\n时,只会显示第一行。我正在尝试设置一个标题,下一行是更多的文本。那么,在UIRefreshControl
中使用两行文本的解决方法是什么?
以下是当前代码,只显示“Title Here”:
self.refreshControl = [[UIRefreshControl alloc] init];
NSString *title = @"Title Here";
NSString *subText = @"Subtext Here";
NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n%@",title,subText]];
[attString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica" size:20.0f] range:NSMakeRange(0, [title length])];
[attString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica" size:14.0f] range:NSMakeRange([title length],[subText length])];
[attString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, [title length])];
[attString addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange([title length], [subText length])];
self.refreshControl.attributedTitle = attString;