ios - UITextfield 的位置未正确设置

标签 ios objective-c uitextfield

我正在制作一个应用程序,我想设置 UITextfield 的位置。但我陷入其中,它只设置垂直位置而不是水平位置。下面是我的代码和屏幕截图

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

最佳答案

使用CATransform3DMakeTranslation不要忘记导入Quartzcore框架

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

关于ios - UITextfield 的位置未正确设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27182573/

相关文章:

ios - 在 Storyboard 中放置 UILabel

ios - 如何自动布局并将应用程序部署到应用程序商店

ios - 使用 IQKeyboardReturnKeyHandler 在键盘上方显示 uitextfield

ios - Swift UITextField 小数字段类型 - 不粘贴、仅 1 个小数点和长度限制

swift - 如何在 UITextfield 中的每个逗号后添加一个字符串

ios - 如何在 MKMapView 中找到中国变换的逆?

javascript - iOS 上的 JQuery Mouseup

ios - 场景的子元素发布速度不够快?

iphone - 初始化 2 个昏暗数组 NSMutableArray

ios - 为什么看不到按钮?