点击或保存字体图标时的问号

所以我最近开始修改我的应用程序,以获得它与iOS 11兼容。 幸好大部分似乎是。

但是我注意到,在我的工具栏中,如果我点击或点击并按住font​​ello的ttf文件提供的图标,我会得到一个问号框。

图标示例:

menu = [[UIBarButtonItem alloc] initWithTitle:@"\ue811" style:UIBarButtonItemStylePlain target:self action:@selector(openMenu:)]; [menu setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"fontello" size:23], NSForegroundColorAttributeName:[[UIColor alloc] initWithWhite:1.f alpha:1.f]} forState:UIControlStateNormal]; 

它在10.3.1模拟器中工作正常。 只是iOS 11似乎被搞砸了。 我已经阅读了关于设备的修复,这意味着更新操作系统,但模拟器运行11.2,所以理论上应该修复。

有其他人有这个问题吗? 知道一个修复?

只需为UIControlStateSelected添加标题文本属性:

 [menu setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"fontello" size:23], NSForegroundColorAttributeName:[UIColor greenColor]} 

forState:UIControlStateSelected];

正如评论中所提到的,iOS 11要求您设置正常状态和选定/突出显示状态。 以下是为我工作。 根据你有很多button,不需要额外的代码,但是哦。

  [menu setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"fontello"size:23], NSForegroundColorAttributeName:[[UIColor alloc] initWithWhite:0.f alpha:1.f]} forState:UIControlStateNormal]; [menu setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"fontello"size:23], NSForegroundColorAttributeName:[[UIColor alloc] initWithWhite:0.f alpha:0.5f]} forState:UIControlStateHighlighted]; 
Interesting Posts