小编ggf*_*ela的帖子

UIRefreshControl来源于标题多行

是否可以在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;
Run Code Online (Sandbox Code Playgroud)

objective-c ios uirefreshcontrol

4
推荐指数
1
解决办法
2636
查看次数

标签 统计

ios ×1

objective-c ×1

uirefreshcontrol ×1