LeftView UITextField Shift

I am trying to customize my UITextField object as it enter image description here

but the leftView is shifted to the right by a few pixels since

enter image description here

how can i reposition my UITextField.leftView

Here is my code

 NSArray *itemArray = @[@"<", @">"]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(0, 0, 60, 26); segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain; _urlTextField.leftView = segmentedControl; _urlTextField.leftViewMode = UITextFieldViewModeAlways; 
+4
source share
2 answers

Try it...

 NSArray *itemArray = @[@"<", @">"]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; **segmentedControl.center = CGPointMake(03, 15);** segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain; self.textField.leftView = segmentedControl; self.textField.leftViewMode = UITextFieldViewModeAlways; 

Also change the border style of the text box except the rounded rectangle.

Hope this helps

Regards, Paggy123

+1
source

UITextField does not provide a property like frame for leftView ; it has only one property, similar to borders, makes it look like the position of the positions of the buttons on the navigation bar; we cannot reposition the leftView . See here for reference.

+1
source

All Articles