Je veux créer un UIBarButtonItem avec une image personnalisée, mais je ne veux pas la frontière de l'iPhone ajoute, comme mon Image a une frontière.
C'est le même que le bouton de retour, mais un bouton vers l'avant.
Cette Application est pour un projet interne, donc je ne m'inquiète pas si Apple rejeter ou s'il l'approuve ou il aime :-)
Si j'utilise le initWithCustomView:v de la propriété de la UIBarButtonItem, je peux le faire:
UIImage *image = [UIImage imageNamed:@"right.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage: [image stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateNormal];
[button setBackgroundImage: [[UIImage imageNamed: @"right_clicked.png"] stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateHighlighted];
button.frame= CGRectMake(0.0, 0.0, image.size.width, image.size.height);
[button addTarget:self action:@selector(AcceptData) forControlEvents:UIControlEventTouchUpInside];
UIView *v=[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ];
[v addSubview:button];
UIBarButtonItem *forward = [[UIBarButtonItem alloc] initWithCustomView:v];
self.navigationItem.rightBarButtonItem= forward;
[v release];
[image release];
Cela fonctionne, mais si je dois répéter ce processus en 10 points de vue, ce n'est pas SÈCHE.
Je suppose que j'ai à la sous-classe, mais quoi ?
- NSView ?
- UIBarButtonItem ?
merci,
en ce qui concerne,