如何在uiLabel中包含粗体和非粗体文本?
我宁愿不使用UIWebView ..我也读过这可能是使用NSAttributedString,但我不知道如何使用它.有任何想法吗?
Apple在他们的几个应用程序中实现了这一点; 示例截图:
谢谢! - Dom
我在tableview单元格上使用标签.已为单元格分配了一个属性字符串,但问题是在选择时,单元格文本对于属性字符串不会变为白色.
有没有办法解决它..?
任何帮助表示赞赏.
这是我的代码.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
LHSearchViewCell *cell = [LHSearchViewCell cellForTableView:tableView fromNib:_cellNib];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.headerLabel.textColor = [UIColor darkGrayColor];
cell.headerLabel.highlightedTextColor = [UIColor whiteColor];
cell.headerLabel.font = [UIFont systemFontOfSize:14];
cell.subLabel.font = [UIFont systemFontOfSize:12];
cell.subLabel.textColor = [UIColor darkGrayColor];
cell.subLabel.numberOfLines = 2;
switch (indexPath.section) {
case 0:
{
UIFont *font = [UIFont systemFontOfSize:14.0];
NSDictionary *firstAttributes = [NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,[UIColor darkGrayColor],NSForegroundColorAttributeName,nil];
UIFont *secondFont = [UIFont systemFontOfSize:10.0];
NSDictionary *secondAttributes = [NSDictionary dictionaryWithObjectsAndKeys:secondFont,NSFontAttributeName,[UIColor lightGrayColor],NSForegroundColorAttributeName,nil];
NSString* completeString = [NSString …Run Code Online (Sandbox Code Playgroud) 我有这个字符串,我想在标签中显示:
NSString *criticsScore=[NSString stringWithFormat:@"%@\%%",[dict objectForKey:@"critics_score"]];
_criticRating.text=criticsScore;
Run Code Online (Sandbox Code Playgroud)
我想设置一个小字体\%%和一个大字体[dict objectForKey:@"critics_score"]];
这是否可能?