How to apply Pictos font to UIButton in iOS

544 Views Asked by At

I want to use Home button with home icon, but I want to use actual font instead of graphics.

For e.g) I will set UIButton title to "H" and set Pictos font it, so that it should automatically convert button text into corresponding graphics(In this case home icon)

How to do it using pictos font?

1

There are 1 best solutions below

0
Gaurav Borole On BEST ANSWER

Finally got "Pictos" font in .otf format from photoshop. Pictos font is available in photoshop.

Steps:

  1. Export Pictos font in .otf format from photoshop.
  2. Add custom font to your application, you can add them to the XCode project.
  3. Modify the application-info.plist file. Add the key "Fonts provided by application" to a
    new row. Add one item for pictos font you have added. enter image description here

  4. Create button and set Pictos font.

    UIButton *homeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    homeButton.frame = CGRectMake(0, 0, 34 , 33);
    [homeButton setTitle:@"H" forState:UIControlStateNormal];
    homeButton.titleLabel.font = [UIFont fontWithName:@"Pictos" size:22];
    
  5. You will see button with Home icon like enter image description here

Note: You can set different icons by setting proper title text. enter image description here