UITextField's custom font changes while in edit mode


I have a UITextField that is loaded from a xib. In it's view controllers viewDidLoad method, I set the font to a custom value which is set up correct in the .plist file and everything. It displays fine except for when it is in edit mode, at which point the font switches from my custom font to the default font, which I believe is Helvetica. This is jarring, and I'd like to keep the custom font throughout. I've looked around and I don't see any immediate solution, the only thing I've tried is resetting the textField.font property in the textFieldShouldBeginEditing and textFieldDidBeginEditing delegate methods, neither of which did anything.

Edit: I've been asked for the code, it really only is one line but here goes.

- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. self.myTextField.font = [UIFont fontWithName:@"MyFont" size:18]; }

I've also tried resetting the font in the following two methods:

-(void)textFieldDidBeginEditing:(UITextField *)textField { textField.font = [UIFont fontWithName:@"MyFont" size:18]; } -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField { textField.font = [UIFont fontWithName:@"MyFont" size:18]; return YES; }

This does nothing, the font still changes while editing takes place, but then changes back to the custom font once the keyboard is dismissed.

Second edit:

Well, I just did something I probably should have tried before, and used a couple of different font files. Both of those fonts worked fine, but for whatever reason the custom font file I was using is causing the problem, despite it working normally in all other situations.


I had this problem with an otf font (in fact I've always had problems with otf fonts...) so now I use only ttf fonts, which work great. Check out this <a href="http://onlinefontconverter.com/" rel="nofollow">font converter website</a> if you need to convert fonts from otf.


Try this:

- (void)textFieldDidChange:(UITextField *)textField { textField.font = [UIFont fontWithName:@"MyFont" size:18]; }

Or as an alternative to fhat create an IBAction, connect it to the textField with Editing Changed and add this code to your .m:

- (IBAction)textFieldEditingChanged:(id)sender { textField.font = [UIFont fontWithName:@"MyFont" size:18]; }


From my experience, the problem is with the font file. I found that the only solution was to find an alternative font and switch.


  • How can I use scipy optimization to find the minimum chi-squared for 3 parameters and a list of data
  • How to issue a command that produces infinite output and return immediately
  • Can I customize a Jackson ObjectMapper by adding a module?
  • UIImagePickerControllerDelegate Methods Not Called When Delegate Not UIViewController
  • JOOQ nested condition
  • three.js WebVR example code works on threejs.org but not on my local server
  • Wrap assemblies in .NET?
  • Using an enum contained in a Cloud Endpoint model on a Android client
  • Retrieve Facebook Account Information in ios 6
  • retrieving data from url in iphone
  • Opaque reference instead of PImpl. Is it possible?
  • Get Currently Active User in Android
  • jquery validation - waiting for remote check to complete
  • LiveData is abstract android
  • Compare struct to a constant in C
  • Creating PDF from TIFF image using iText
  • Why must we declare a variable name when adding a method to a struct in Golang?
  • Pycharm: Marking a folder as 'sources root' is not recursive for subfolders
  • ThreadStatic in asynchronous ASP.NET Web API
  • Sending keystrokes/mouse clicks to a Java program with Autohotkey
  • Build Successful but not running on simulator
  • how to save the state in userdefaults of accessory checkmark-iphone
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Blackberry - Custom EditField Cursor
  • Hardware Accelerated Image Scaling in windows using C++
  • Android full screen on only one activity?
  • Refering to the class itself from within a class mehod in Objective C
  • Django: Count of Group Elements
  • How to do unit test for HttpContext.Current.Server.MapPath
  • Azure Cloud Service Web Role web pages do not load
  • Fetching methods from BroadcastReceiver to update UI
  • swift auto completion not working in Xcode6-Beta
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • Symfony2: How to get request parameter
  • Getting 'uninitialized constant' error when using delegate in belongs_to in model
  • GridView Sorting works once only
  • Cannot Parse HTML Data Using Android / JSOUP
  • WPF Applying a trigger on binding failure
  • Suggestions to manage Login/Logout transitions
  • C# - Getting references of reference