【发布时间】:2013-04-22 11:33:08
【问题描述】:
是否可以在UIRefreshControl 标题中使用多行?每当我将 \n 添加到 NSAttributedString 时,只会显示第一行。我正在尝试设置标题,并在下一行设置更多文本。那么有没有解决方法在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;
【问题讨论】:
标签: ios objective-c uirefreshcontrol