2011-04-11 16 views
8

agrego botón personalizado de control de navegaciónAñadir botón personalizado de control de navegación sin borde

 
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] 
                    style:UIBarButtonItemStylePlain 
                    target:self 
                    action:@selector(backAction)]; 
    self.navigationItem.leftBarButtonItem = backButton; 

funciona bien, pero botón aparece con borde. ¿Cómo puedo arreglar eso?

ACTUALIZACIÓN He encontrado la solución

 
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)]; 
    [button setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal]; 
    [button addTarget:self action:@selector(buttonFavoriteClicked) forControlEvents:UIControlEventTouchUpInside]; 
    UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithCustomView:button]; 
    [button release]; 
self.navigationItem.leftBarButtonItem = back; 

Respuesta

12

Prueba esto.

UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, button_width, button_height)]; 
[backButton setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal]; 
[backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; 
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; 
Cuestiones relacionadas