2010-07-16 18 views
44

C'è un modo per allineare verticalmente il testo in un UITextField a metà strada tra UIControlContentVerticalAlignmentCenter e UIControlContentVerticalAlignmentBottom o devo andare con uno di quelli?UITextField Vertical Alignment

+0

Eventuali duplicati di http://stackoverflow.com/questions/2694411/text-inset-for-uitextfield – titaniumdecoy

+1

@titaniumdecoy Non è. –

risposta

4

Si dovrebbe sottoclasse un UITextField, e sovrascrivere i seguenti metodi:

- (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); 
}