0

I am working on an iOS app that can edit text. User can change the font style by clicking a UIButton. Basically it change "Bold"

 -(IBAction)boldButton:(id)sender{

if([fontName length] >6){

    if ([[fontName substringFromIndex:[fontName length]-6] isEqual:@"Italic"] ) {

        fontName = [fontName substringToIndex:[fontName length]-7];
    }
}

if ([fontName length] >4) {
    if ([[fontName substringFromIndex:[fontName length]-4] isEqual:@"Bold"] ) {
        fontName = [fontName substringToIndex:[fontName length]-5];

    }else{
        fontName =[NSString stringWithFormat:@"%@-Bold",fontName ];
    }
}
      txtVw.font =  [UIFont fontWithName:fontName size:[[NSNumber numberWithFloat:fontSizeSlider.value]integerValue]];
}

But this is not a ideal solution. I have found that , for the arial font name for italic assign as "ItalicMT".then it is not working for arial and some other fonts. What should be the best way to change font style.

Susitha
  • 3,339
  • 5
  • 27
  • 41
  • possible duplicate of [Setting BOLD font on iOS UILabel](http://stackoverflow.com/questions/18862868/setting-bold-font-on-ios-uilabel) – Shai Nov 20 '14 at 09:34
  • @Shai This is not a duplicate question of the above. I have asked a different question. – Susitha Nov 20 '14 at 09:41
  • Check this answer: http://stackoverflow.com/a/21776838/3899770 – Aris Nov 20 '14 at 09:57

0 Answers0