使用兩個TextField或在後臺使用標籤/視圖。將TextField放置在某些視圖/標籤/ TextFields上是不適當的開發。並把標籤或視圖左側是不是我沒想到下面的方法是正確的方法正確的方法要麼如何使UITextField文本輸入在5-6個空格字符後啓動
。所以,我希望有一個更好的解決方案
UILabel * leftView = [[UILabel alloc] initWithFrame:CGRectMake(10,0,7,26)];
leftView.backgroundColor = [UIColor clearColor];
textField.leftView = leftView;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
我們如何使用後,實現它
// placeholder position
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset(bounds , 10 , 10);
}
// text position
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectInset(bounds , 10 , 10);
}
我能夠使用來實現。但有那麼一些更好的方法在此的UITextField
Txt_SecurityAns.layer.sublayerTransform = CATransform3DMakeTranslation(5, 0, 0);
Txt_Email.layer.sublayerTransform = CATransform3DMakeTranslation(5, 0, 0);
看看[添加插圖中的UITextField(http://stackoverflow.com/questions/2694411/text-inset-for-uitextfield) – Apoorv
如何使用我沒有得到它//佔位符位置 - (CGRect)textRectForBounds:(CGRect)bounds {return} CGRectInset(bounds,10,10); } //文本位置 - (CGRect)editingRectForBounds:(CGRect)bounds {return} CGRectInset(bounds,10,10); } –