UITextView problema rientro:
Ad esempio, voglio il testo "test" un po 'a destra, quale proprietà dovrei impostare?
UITextView problema rientro:
Ad esempio, voglio il testo "test" un po 'a destra, quale proprietà dovrei impostare?
Creare una sottoclasse e sovrascrivere textRectForBounds:
e editingRectForBounds:
. I tuoi nuovi implementazioni possono essere simile
- (CGRect)textRectForBounds:(CGRect)bounds;
{
return CGRectInset([super textRectForBounds:bounds], 10.f, 0.f);
}
- (CGRect)editingRectForBounds:(CGRect)bounds;
{
return CGRectInset([super editingRectForBounds:bounds], 10.f, 0.f);
}
Prova questa
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
self.yourtextField.leftView = paddingView;
self.yourtextField.leftViewMode = UITextFieldViewModeAlways;
Funziona senza sottoclassi. Il miglior metodo IMHO. Grazie. – rmvz3
Ottima risposta, mi ha salvato la vita! –
Quale ID voglio rientrare dall'alto –
Basta provare come questo metodo semplice ....
textfield.frame = CGRectMake(textfield.frame.origin.x+10, textfield.frame.origin.y, textfield.frame.size.width, textfield.frame.size.height);
Un po 'a destra o completamente a destra? – Ravi
@Ravi little bit –
http://stackoverflow.com/questions/7565645/indent-the-text-in-uitextfield – Fattie