2011-03-02 10 views

Respuesta

11

tratar

[buttonLeft.titleLabel setLineBreakMode:NSLineBreakByWordWrapping]; 
+0

wow que funcionó ... muchas gracias por la respuesta .... !! .. :) – devsri

1

pueden intentar lo siguiente. es un poco largo, pero creo que funcionará:

// solo queremos agregar nuestra etiqueta personalizada una vez; solo el 1.er paso devolverá nil UILabel titleLabel = (UILabel) [self viewWithTag: TITLE_LABEL_TAG];

if (!titleLabel) 
{ 
    // no custom label found (1st pass), we will be creating & adding it as subview 
    titleLabel = [[UILabel alloc] initWithFrame:titleRect]; 
    [titleLabel setTag:TITLE_LABEL_TAG]; 

    // make it multi-line 
    [titleLabel setNumberOfLines:0]; 
    [titleLabel setLineBreakMode:UILineBreakModeWordWrap]; 

    // title appearance setup; be at will to modify 
    [titleLabel setBackgroundColor:[UIColor clearColor]]; 
    [titleLabel setFont:[self font]]; 
    [titleLabel setShadowOffset:CGSizeMake(0, 1)]; 
    [titleLabel setTextAlignment:UITextAlignmentCenter]; 

    [self addSubview:titleLabel]; 
    [titleLabel release]; 
} 

// finally, put our label in original title view's state 
[titleLabel setText:title]; 
[titleLabel setTextColor:titleColor]; 
[titleLabel setShadowColor:titleShadowColor]; 

// and return empty rect so that the original title view is hidden 
return CGRectZero; 

}

+0

UIButton ya tiene TitleLabel personalizable dentro, así que no es necesario crear otro – Vladimir

10

Para UILabel, la constante apropiada es ahora NSLineBreakByWordWrapping (en lugar de UILineBreakModeWordWrap):

titleLabel.lineBreakMode = NSLineBreakByWordWrapping; 
0

Sólo retirar y reemplazar estas enumeraciones.

En los Previos de iOS6 fue: - enter image description here

De IOS 6 que es: -

enter image description here