gpt4 book ai didi

ios - UITextfield 的位置设置不正确

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:02:53 25 4
gpt4 key购买 nike

我正在制作一个应用程序,我想设置 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com