2

我有 iphone 应用程序,其中有文本字段,它工作正常,但问题是它显示文本字段顶部的文本,我希望它垂直居中对齐。这是我的文本字段代码。

  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;
4

1 回答 1

2

使用以下代码对中的文本进行垂直对齐UITextFiled

MyTextFieldName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
于 2013-09-02T05:27:17.703 回答