Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • String with different colors in iPhone

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 411
    Comment on it

    Using addAttribute method we can add different colors to a string for certain range of characters in that string.

    Label.text = @"Ashish";
        NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString: Label.attributedText];
        [text addAttribute: NSForegroundColorAttributeName value: [UIColor colorWithRed:8/255.0 green:136/255.0 blue:228/255.0 alpha:1] range: NSMakeRange(0, 2)];
        [Label setAttributedText: text];
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: