martes, 6 de octubre de 2015

iOS: UIView padding

self.view.contentInset = UIEdgeInsetsMake(5.0f, 5.0f, 5.0f, 5.0f);

UILabel
Subclass it and override

- (void)drawTextInRect:(CGRect)rect {
    UIEdgeInsets insets = {5, 5, 5, 5};
    [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];

}

UITextField
Subclass it and override

- (CGRect)textRectForBounds:(CGRect)bounds
{
    return CGRectInset(bounds, 5.0f, 0);
}

- (CGRect)editingRectForBounds:(CGRect)bounds
{
    return [self textRectForBounds:bounds];
}

No hay comentarios:

Publicar un comentario