Mishal Awan Mishal Awan - 6 months ago 15
Objective-C Question

position of UITextfield not setting properly

I am making an app i want to set my position of

UITextfield
. but i am stuck in it, it is setting only
vertical position
not
horizontal position
. below is my code and screen shot

Msgtextfield.placeholder=@"demo";
CGRect frame = CGRectMake(100,100,10,100);
UILabel * leftView = [[UILabel alloc] initWithFrame:frame];
leftView.backgroundColor = [UIColor clearColor];
self.Msgtextfield.leftView = leftView;
self.Msgtextfield.leftViewMode = UITextFieldViewModeAlways;
self.Msgtextfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
self.Msgtextfield.contentHorizontalAlignment=UIControlContentHorizontalAlignmentCenter;


i want the text starting from the topleft corner of uitextfield

Answer

use CATransform3DMakeTranslation don't forget to import Quartzcore framework

 self.Msgtextfield.layer.sublayerTransform=CATransform3DMakeTranslation(5, 0, 0);