Text with different Background Colour ,Corner Radius and Font , Just as in basecamp

287 Views Asked by At

I want text in one flow in UITableViewCell . The text have different attributes . I am referring basecamp application for design reference . In basecamp Task Name followed by assigned member with date . Every part have own attributes .

Tried using different UIlabels But result is not achieved .

Someone told me to use CoreText But i don't know how ?

1

There are 1 best solutions below

1
On

Use AttributedString for that solution

NSMutableAttributedString *aboutText = [[NSMutableAttributedString alloc] initWithString:@"Sellcle\n\n Sellcle is a mobile marketplace app for Second hand, used, antique or simply beautiful things in your neighborhood and sell your things quickly to other people around you. Simply snap-a-shot, list it, and start selling on the go.\n\nQuestions & Support\n\[email protected]"];

    [aboutText beginEditing];

    [aboutText addAttribute:NSFontAttributeName
                         value:[UIFont boldSystemFontOfSize:14]
                         range:NSMakeRange(0,7)];

    [aboutText addAttribute:NSFontAttributeName
                      value:[UIFont boldSystemFontOfSize:14]
                      range:NSMakeRange(240,20)];

    [aboutText addAttribute:NSForegroundColorAttributeName
                      value:[UIColor blueColor]
                      range:NSMakeRange(260,21)];

    [aboutText addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(260,21)];
    [aboutText endEditing];

    label.attributedText = aboutText;

Try above code I think it helps you.