Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITextfield。尽管在代码和属性检查器-Swift/Xcode中设置了文本颜色,但文本颜色不起作用_Ios_Swift_Xcode_Uitextfield_Uistoryboard - Fatal编程技术网

Ios UITextfield。尽管在代码和属性检查器-Swift/Xcode中设置了文本颜色,但文本颜色不起作用

Ios UITextfield。尽管在代码和属性检查器-Swift/Xcode中设置了文本颜色,但文本颜色不起作用,ios,swift,xcode,uitextfield,uistoryboard,Ios,Swift,Xcode,Uitextfield,Uistoryboard,我正在尝试设置UIStoryboard上两个文本字段的文本颜色。我尝试在属性检查器和代码中设置颜色。不管怎样,每次我运行模拟器时,文本颜色都是清晰的,只是呈现主视图的背景色 下面是我设置文本颜色的代码。在名为MemeTextAttributes的数组中设置颜色,然后将该数组设置为viewDidLoad()中文本\字段\名称.defaultTextAttributes的值 属性化文本处于过度统治状态it@MadProgrammer您是指“属性检查器”和“代码”中的颜色设置吗?如果是这样的话,我在

我正在尝试设置UIStoryboard上两个文本字段的文本颜色。我尝试在属性检查器和代码中设置颜色。不管怎样,每次我运行模拟器时,文本颜色都是清晰的,只是呈现主视图的背景色

下面是我设置文本颜色的代码。在名为MemeTextAttributes的数组中设置颜色,然后将该数组设置为viewDidLoad()中文本\字段\名称.defaultTextAttributes的值


属性化文本处于过度统治状态it@MadProgrammer您是指“属性检查器”和“代码”中的颜色设置吗?如果是这样的话,我在代码和属性中分别设置了颜色,就像在我分别测试它们时一样,但仍然不起作用。我是说属性文本包含将要使用的格式信息,它忽略了文本字段的属性。你看到情节提要中的颜色变化了吗?好的,只需在textField.textColor中设置颜色,它就工作了。谢谢
let memeTextAttributes: [NSAttributedString.Key: Any] = [
     NSAttributedString.Key.strokeColor: UIColor.black,
     NSAttributedString.Key.foregroundColor: UIColor.purple,
     NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
     NSAttributedString.Key.strokeWidth: 2.0
]

override func viewDidLoad() {
    super.viewDidLoad()
    self.topTxtField.delegate = self
    self.bottomTxtField.delegate = self
    topTxtField.text = "TOP"
    topTxtField.textAlignment = NSTextAlignment.center
    bottomTxtField.text = "BOTTOM"
    bottomTxtField.textAlignment = NSTextAlignment.center
    topTxtField.defaultTextAttributes = memeTextAttributes
    bottomTxtField.defaultTextAttributes = memeTextAttributes
}