将图像添加到导航栏中

时间:2011-02-18 11:22:13

标签: iphone cocoa-touch uinavigationbar

将项目添加到收藏夹时。我想表明它已成功添加到用户,方法是将星形图像淡入,导入栏中代替右侧栏按钮。我怎么能这样做?

任何帮助将不胜感激!谢谢

1 个答案:

答案 0 :(得分:0)

您可以使用自定义按钮自定义右侧栏按钮项。

//custom back button
    button =  [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [button setFrame:CGRectMake(-2, 0, 52, 30)];

    UIBarButtonItem *btnItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.rightBarButtonItem = btnItem;
    [btnItem release];