gpt4 book ai didi

ios - Font Awesome 图标不适用于 UIButton IBOutlet

转载 作者:行者123 更新时间:2023-11-29 01:53:09 25 4
gpt4 key购买 nike

我正在尝试在我的 Xcode 项目中实现 FontAwesome 的图标。我已将 fontawesome.ttf 文件放入我的项目中,我正在使用来自此 github 的代码将它们放入我的 UIButtonUIImageView >:https://github.com/alexdrone/ios-fontawesome .

我可以通过在此处的 github 演示中执行此示例代码,将图标添加到我的应用程序中:

FAImageView *imageView = [[FAImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, 100.f, 100.f)];
imageView.image = nil;
[self.view addSubview:imageView];

UIImage *icon = [UIImage imageWithIcon:@"fa-github" backgroundColor:[UIColor purpleColor] iconColor:[UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:255] fontSize:50];
UIImageView *github = [[UIImageView alloc] initWithImage:icon];
CGRect rect = github.frame;
rect.origin.y += CGRectGetMaxY(imageView.frame);
github.frame = rect;
[self.view addSubview:github];

但是,我试图使用以下代码将 FontAwesome 图标放入 UIButton 的 ImageView (位于连接到 IBOutlet 的 Storyboard 中):

self.backOneSentenceButton.imageView.image = [UIImage imageWithIcon:@"fa-backward" backgroundColor:[UIColor blackColor] iconColor:[UIColor blackColor] andSize:self.backOneSentenceButton.bounds.size];

但是按钮中根本没有显示图标,它只是一个普通的白色按钮。这里有什么我可能会遗漏的吗?还是我做的完全错了?任何帮助或建议将不胜感激。谢谢。

最佳答案

只需将图像类设置为您添加的库即可。

enter image description here

希望这对您有所帮助。

关于ios - Font Awesome 图标不适用于 UIButton IBOutlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31195209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com