【发布时间】:2012-07-05 04:13:16
【问题描述】:
我使用UILabel 作为UITextField 的leftView。问题是 textField 的文本高于标签的文本。
这是我目前使用的代码
UILabel *startsWith = [[UILabel alloc] init];
startsWith.font = [UIFont systemFontOfSize:14];
startsWith.textColor = [UIColor blackColor];
startsWith.backgroundColor = [UIColor clearColor];
startsWith.text = @"Text";
[startsWith sizeToFit];
self.textField.leftViewMode = UITextFieldViewModeAlways;
self.textField.leftView = startsWith;
我尝试稍微改变标签的框架,但没有成功...
如何对齐两个文本?
【问题讨论】:
-
你可以尝试继承
UITextField然后覆盖- (CGRect)leftViewRectForBounds:
标签: ios xcode ios5 uitextfield uilabel