我在我的iOS应用程序中使用属性字符串来为文本添加样式:
NSDictionary *titleAttributes = @{NSFontAttributeName: [UIFont fontWithName:@"Raleway" size:12],
NSForegroundColorAttributeName: [UIColor lightGreyTextColor]};
NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:title attributes:titleAttributes];
问题是在iOS 6中,文本不再垂直居中于
UILabel
。在iOS 7上是正常的。我发现当我删除
NSForegroundColorAttributeName
属性时,它就可以正确地居中,但文本是黑色的。有人知道如何解决吗?这是iOS的一个bug还是我漏了什么?