将图像添加到导航栏

发布于 2024-10-18 04:28:03 字数 82 浏览 6 评论 0原文

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

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

When a item is added to favorites. I would like to indicate that it has been successfully added to the user by having a image of a star to fade in, into the navigation bar in place of the right bar button. How can I do this?

Any help will be appreciated! Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唯憾梦倾城 2024-10-25 04:28:03

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

//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];

You can customize your right bar button item using custom button.

//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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文