0

I have an app where the users enters information in a few textfields which are then added to a uitextview by a nsstring does anybody know how i can set one of the textfields to italics and keep the others normal

regards

Edit:

Heres my code i want to only change once textfield (e.g textfbookpublisher):

NSString* combinedString = [NSString stringWithFormat:
                            @"%@,%@.'%@.'%@.%@,%@.", 
                            textfbookpublisher.text,
                            textfbookauthor.text,
                            textfbooktitle.text,
                            textfbookplace.text,
                            nameofuni.text,
                            textfbookyear.text];



DissertationGen*bookg = [[DissertationGen alloc] init];
bookg.message = combinedString;
bookg.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:bookg animated:YES]

2 Answers2

1

A quick search would have given you an easy answer. For example, this post.

Simply set the font of the UITextfield you want to a [UIFont italicSystemFontOfSize:].

Community
  • 1
  • 1
Jonathan M
  • 1,891
  • 13
  • 21
  • how would i implement this into my code above? sorry im pretty new to this. thanks – Dom Kennedy Oct 03 '12 at 21:32
  • I see. You are trying to get a single word in a NSString to be displayed in italic, while the rest is normal. You could try some custom controls that might support it, but using only basic controls, your best shot is probably splitting the text into multiple UILabels when you display it. – Jonathan M Oct 05 '12 at 19:13
0

try this link see accepted answer and also check TTTAttributedLabel library

Bold one Word

now you want only textfbookpublisher in italic then pass it individually to next DissertationGen view

in DissertationGen controller's viewdidload method use following code

UILabel *lblpubl = [[UILabel alloc] init];
lblpubl.font = [UIFont italicSystemFontOfSize:18.0];
lblpubl.text = your variable which contains textfbookpublisher's text;

now use lblpubl as you wish

P R J
  • 428
  • 5
  • 18
  • Hi thanks for the answer, it is only italicising when i type in the textfield but when it is transferred to the uitextview the word i entered is no longer italics – Dom Kennedy Oct 04 '12 at 11:36
  • @DomKennedy i have added one link try it & tell me it solved your problem or not. – P R J Oct 04 '12 at 12:42
  • thanks for the link but sorry it still hasnt solved my problem, I cant seem to work it by implementing the example you gave me. I think my problem is alot more simple than that. – Dom Kennedy Oct 04 '12 at 14:16