2010-07-16 13 views
44

¿Hay una forma de alinear verticalmente el texto en un UITextField a medio camino entre UIControlContentVerticalAlignmentCenter y UIControlContentVerticalAlignmentBottom o tengo que ir con uno de esos?UITextField Alineación vertical

+0

duplicado Posible de http://stackoverflow.com/questions/2694411/text-inset-for-uitextfield – titaniumdecoy

+1

@titaniumdecoy No lo es. –

Respuesta

4

Debe subclase un UITextField, y anular los métodos siguientes:

- (CGRect) textRectForBounds: (CGRect) bounds 
{ 
    CGRect origValue = [super textRectForBounds: bounds]; 

    /* Just a sample offset */ 
    return CGRectOffset(origValue, 0.0f, 4.0f); 
} 

- (CGRect) editingRectForBounds: (CGRect) bounds 
{ 
    CGRect origValue = [super textRectForBounds: bounds]; 

    /* Just a sample offset */  
    return CGRectOffset(origValue, 0.0f, 4.0f); 
} 
Cuestiones relacionadas