Is it possible to align placeholder in the middle of a UITextField? And when we start editing it should it start from left corner of UITextField? I am new to iOS.
Here is the sample code for that.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
txtList.textAlignment = NSTextAlignmentCenter;
}
// This method is called once we click inside the textField
-(void)textFieldDidBeginEditing:(UITextField *)textField{
txtList.textAlignment = NSTextAlignmentLeft;
}
Don't forgot to give delegate of UITextField.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With