4

I have a UITextfield & I am going to apply the vertical alignments to it(top,bottom,center). I done it correctly by setting the vertical alignment. But when I transform the textfield using (-M_PI/2) and apply bottom or center alignment, then it works fine but text in textfield is not visible to user. If anyone knows the solution regarding this then please help me . Thanks in advance.

Pfitz
  • 7,336
  • 4
  • 38
  • 51
Girish
  • 4,692
  • 4
  • 35
  • 55
  • http://stackoverflow.com/questions/5439099/how-do-i-vertically-center-uitextfield-text/23577643#23577643 – Kumar KL May 10 '14 at 06:01

1 Answers1

14

try may work for u

  textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

  textField.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
gauravds
  • 2,931
  • 2
  • 28
  • 45
  • In viewDidLoad, I set the frame of textfield as (100,100,250,40) & then transform it. I think width set to height because of transforming the textfield & viceversa. – Girish Jun 18 '12 at 11:01
  • I didn't get u; 250 is width and 40 is height – gauravds Jun 19 '12 at 04:46
  • UIControlContentHorizontalAlignmenCenter UIControlContentVerticalAlignmenTop is it nor work for u – gauravds Jun 22 '12 at 10:28
  • Code which I written is as follows - self.txtMessage = [[UITextField alloc] init]; self.txtMessage.frame = CGRectMake(430.0, 140.0, 250.0, 40.0); self.txtMessage.transform = CGAffineTransformMakeRotation(-M_PI/2); [self.txtMessage1 setClipsToBounds:YES]; For top alignment, I written the following code & similarly to other. txtcurrentTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop; txtcurrentTextField.contentVerticalAlignment = UIControlContentHorizontalAlignmenCenter – Girish Jun 26 '12 at 12:24