OGeek|极客世界-中国程序员成长平台

标题: ios - 如何获取 "Star"(收藏夹)UIBarButtonItem 的图像? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 21:11
标题: ios - 如何获取 "Star"(收藏夹)UIBarButtonItem 的图像?

我是 iOS 新手。我希望在我的应用程序的顶部菜单上放置一个“星”按钮。有没有办法让 iOS 中内置的星形按钮类似于 UIBarButtonSystemItemAdd

如果没有,我怎样才能获得类似于 Apple 在 iOS 中使用的常见收藏夹星的图像?

与此类似:

enter image description here



Best Answer-推荐答案


一个简单快捷的方法是使用 FontawesomeKit .
您可以像这样轻松创建按钮:

FAKFontAwesome *icon = [FAKFontAwesome starIconWithSize:20];
[icon addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor]];
UIBarButtonItem *favButton = [[UIBarButtonItem alloc] initWithImage:[icon imageWithSize:CGSizeMake(20, 20)]
                                                         style:UIBarButtonItemStylePlain
                                                        target:self
                                                        actionselector(doSomething];

关于ios - 如何获取 "Star"(收藏夹)UIBarButtonItem 的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22815882/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4