I am unable to set custom font in NSMutableAttributedString
But when setting font to System it's working fine. Here is my code:
NSString *str=@"my attributed text";
NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] initWithString:str];
UIFont *customFont =[UIFont fontWithName:@"Play-Regular" size:13.0];
[attString addAttributes:@{
NSForegroundColorAttributeName: [UIColor colorWithRed:111.0/255.0 green:75.0/255.0 blue:26.0/255.0 alpha:1.0],
NSFontAttributeName: customFont,
} range:NSMakeRange(0,str.length)];
I am unable to set custom font in UISearchbar.
[[UITextField appearanceWhenContainedIn: [UISearchBar class], nil] setDefaultTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont fontWithName:@"Play-Regular" size:13.0]}];
Although I have successfully added Play font.
But it working fine when setting
[[UITextField appearanceWhenContainedIn: [UISearchBar class], nil] setDefaultTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:13.0]}];