Search code examples
iosswift2uitextviewtextcolor

Change textColor of a UITextView in Swift


I have an iOS project I'm working on using Xcode7 and Swift2. I have a UITextView that I'm trying to change the textColor of. It has a black background color.

I looked here and could not find a setTextColor. I also tried below in the UIViewController of where the UITextView is located with no luck:

@IBOutlet weak var codeText: UITextView!
override func viewDidLoad() {
    super.viewDidLoad()

    self.codeText.delegate = self

    codeText.textColor = UIColor.whiteColor()
}

I then went into the Inspector and tried clicking on the UITextView and changing the textColor there with no luck of it changing. Am I doing something wrong?

Thank you.


Solution

  • I ended up deleting the UITextField in the Storyboard and putting a new one. I connected it to the ViewController with an @IBOutlet as before. I then went to 'Product' and 'Clean'. Afterwards I ran my my project and it worked fine. I still had the newly added UITextView called codeText assigned to the UITextFieldDelegate and works beautifully. Must have just had a bug in it and needed to start fresh.