属性字符串NSMutableAttributedString使用例子 -- iOS开发

来源:互联网 发布:linux last reboot 编辑:程序博客网 时间:2024/05/02 04:22

这是效果图:简单实现,一目了然效果图

NSDictionary *publicAttrDict_base =@{NSFontAttributeName : [UIFontsystemFontOfSize:14.0f],NSForegroundColorAttributeName :[UIColordarkGrayColor]};

                


               NSString *titleString = [NSStringstringWithFormat:@"参与人:%d", [[_body objectForKey:@"AttendeeCount"]intValue]];

                NSMutableAttributedString *titleAttributeString = [[NSMutableAttributedStringalloc]initWithString:titleStringattributes:publicAttrDict_base];

                [titleAttributeStringaddAttribute:NSForegroundColorAttributeNamevalue:[UIColorgrayColor] range:NSMakeRange(0,4)];

                cell.titleLabel.attributedText = titleAttributeString;

                

               NSString *rightString = [NSStringstringWithFormat:@"实到:%d", [[_body objectForKey:@"SignCount"]intValue]];

                NSMutableAttributedString *rightAttributeString = [[NSMutableAttributedStringalloc]initWithString:rightStringattributes:publicAttrDict_base];

                [rightAttributeStringaddAttribute:NSForegroundColorAttributeNamevalue:[UIColorgrayColor] range:NSMakeRange(0,3)];

                cell.rightLabel.attributedText = rightAttributeString;


0 0
原创粉丝点击