I have 3 RGB sliders in my settings tab that change the color of the background of that specific ViewController. I would also like it to change the color of a text label. The thing is, the text label is on a different view controller. Which means I may probably have to use NSUserDefaults. The text label is a quote on the QOTD Tab.
Problem: How do I change the color of a text label on a different ViewController and let that color be saved until changed?
import UIKit
class colorSliders: UIViewController {
@IBOutlet weak var redSlider: UISlider!
@IBOutlet weak var greenSlider: UISlider!
@IBOutlet weak var blueSlider: UISlider!
override func viewDidLoad() {
super.viewDidLoad()
updateBackgroundColor()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func updateBackgroundColor() {
let red = CGFloat(redSlider.value)
let green = CGFloat(greenSlider.value)
let blue = CGFloat(blueSlider.value)
view.backgroundColor = UIColor(red: red, green: green, blue: blue, alpha: 1)
}
}
This is the code for the RGB sliders.
The ViewController with the quote on it contains:
UILabel! = quoteDisplay
If you need more information, feel free to comment what you would like to see and I will add it immediately. Thank you in advance!
viewController
with thetextLabel
in relation to your color slider? does the slider push theviewController
? or does theviewController
push the slidersviewController
? – NSGangster