Search code examples
iphoneuitextviewuifont

How to change Font Styles For iphone app?


I need to change the font style from bold to italic,by using two buttons.for ex, i am entering the text "this is my iphone application ", after the string "this is"i would like to change the text from bold to italic ( by clicking italic button ) while the previous one remains same.This should apply every time for the button click actions,here is my code

-(IBAction)BoldClicked{
    textView.font = [UIFont boldSystemFontOfSize:18.0];
}
-(IBAction)ItalicClicked{
 textView.font = [UIFont italicSystemFontOfSize:18.0];
}

But the total text is changing..Should I use web view for this?


Solution

  • You can't have two different fonts in one UITextView. You can either use two different UITextViews, or use a UIWebview.