Timothy Rajan
Timothy Rajan

Reputation: 1957

Different Text sizes in the same text view

In my app, I have a UITextview. The data is populated from the DB to this textview. The issue I am having is trivial but not sure how to solve this. The data is a sentence with a time stamp.

For example

Today is new year. Happy New year. Updated at 1-Jan -2014 12:00 PM

I wish the time stamp (i.e. Updated at 1-Jan -2014 12:00 PM) to be appear in a smaller font size than the sentence. Could anyone please help me how to accomplish this task.

The code is below

 NSString *messagetext=[[NSString alloc]init];
 NSString *messagetextwotimestamp=[[NSString alloc]init];
 messagetext=[self getMessageOnefromDB];



 NSString *storytext=messagetext;
 CGSize StoryTextSize = [storytext sizeWithFont:[UIFont fontWithName:@"Myriad Pro" size:16.0] constrainedToSize:CGSizeMake(254, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];

    messageOne.frame=CGRectMake(40, 230, 235, StoryTextSize.height+25);
    messageOne.text=messagetext;
    [messageOne setFont:[UIFont fontWithName:@"Helvetica Neue" size:15.0f]];

Thanks for your time and help

Upvotes: 1

Views: 335

Answers (1)

Matteo Pacini
Matteo Pacini

Reputation: 22846

You're looking for NSAttributedString. Docs here.

Also, look at this question: "How to use NSAttributedString".

Upvotes: 1

Related Questions