我有iphone应用程序,其中我有文本字段它工作正常但问题是它显示文本字段顶部的文本我希望它在中心对齐verticaly。这是我的textfield代码。
herdTextFieldSecond=[[UITextField alloc] initWithFrame:CGRectMake(108,1052,259,36)];
herdTextFieldSecond.textAlignment = UITextAlignmentLeft;
herdTextFieldSecond.textColor = [UIColor blackColor];
herdTextFieldSecond.borderStyle =UITextBorderStyleRoundedRect;
herdTextFieldSecond.text=@"";
herdTextFieldSecond.font = [UIFont fontWithName:@"Helvetica" size:16];
herdTextFieldSecond.delegate=self;
herdTextFieldSecond.layer.borderWidth =1;
herdTextFieldSecond.layer.borderColor = [UIColor darkGrayColor].CGColor;
herdTextFieldSecond.layer.cornerRadius=5;
答案 0 :(得分:2)
使用以下代码对UITextFiled
中的文字进行垂直对齐:
MyTextFieldName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;