Попытка изменить шрифт в моем pickerView с помощью NSAttributedString:Настройка шрифта с помощью NSAttributedString
public func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
guard let castDict = self.castDict else {
return nil
}
let name = [String](castDict.keys)[row]
switch component {
case 0:
return NSAttributedString(string: name, attributes: [NSForegroundColorAttributeName : AppColors.Rose.color, NSFontAttributeName : UIFont.boldSystemFont(ofSize: 14)])
case 1:
guard let character = castDict[name] else {
return NSAttributedString(string: "Not found character for \(name)", attributes: [NSForegroundColorAttributeName : AppColors.Rose.color, NSFontAttributeName : UIFont.boldSystemFont(ofSize: 14)])
}
return NSAttributedString(string: character, attributes: [NSForegroundColorAttributeName : AppColors.LightBlue.color, NSFontAttributeName : UIFont.boldSystemFont(ofSize: 14)])
default:
return nil
}
}
Цвет изменился, шрифт - не:
Что я делаю не так?
Спасибо за подробный ответ. Да, сделал это с помощью пользовательского вида. Всегда старайтесь не использовать представления по соображениям производительности – zzheads