Ios – Change textColor of a UITextView in Swift

iosswift2textcoloruitextview

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.

Best Answer

on your ViewController remove the line

self.codeText.delegate = self

You can not assign a value of type "ViewController" to type "UITextViewDelegate?"

codeText.textColor = UIColor.redColor()

works just fine.

Related Topic