3

Is there any way to get a UITextField to display an NSString containing unicode subscript characters (e.g. ₂ , ₃ ) correctly without cutting them off? I'm starting with a UITextField created in IB.

I've tried:

  • setting the frame.size.height on the UITextField larger in code (just centers the cut-off characters in a taller box)

  • changing the contentVerticalAlignment property to UIControlContentVerticalAlignmentTop- just pushes the cut-off characters to the top

  • playing with the clipSubviews/ Autoresize Subviews- no effect

This is for a chemical program, so it's kinda important to see the bottom half of the numbers. Help!

Jeff
  • 123
  • 5

3 Answers3

1

I haven't found a way to make it work for UITextField.

In my case I used it for placeholder texts. What worked for me was using UILabel for the placeholder texts. These display the subscript correctly.

Roland Keesom
  • 8,180
  • 5
  • 45
  • 52
0

Have you tried setting the font to a smaller size?

textField.font = [UIFont systemFontOfSize:14];

-=-=-=-=-=-

Here's a link to this same question, and they seemed to have solved it by creating a custom UILabel subclass and modifying its (CGSize)sizeThatFits:(CGSize)size method.

Calling method sizeToFit on a UILabel that has subscripts is not working

Community
  • 1
  • 1
Highrule
  • 1,915
  • 3
  • 19
  • 23
  • Yes- no effect. It's kinda pathological how the subscripts are scaled down to the smaller size, then faithfully chopped off again. – Jeff May 17 '12 at 21:45
0

Using the steps here, you could edit your own custom font file you would add to your project, and increase or decrease its ascender and/or descender to allow vertical space for your subscripts.

cohen72
  • 2,830
  • 29
  • 44