心理測驗或問卷 App

with Lüscher color test

Hi there

Today we will do Lüscher color test

If you like to know more please read this wikipedia.

https://en.wikipedia.org/wiki/L%C3%BCscher_color_test

I make this app for simple color test

Pass the result to next page

And one more special is when the button click change the color as same color as color test.

Make some new files and Just simple UI.

Explain what is Lüscher color test, choose the color

and push the next page

Result Veiw Controller Swift

The colorImageView part is color`s for imageview

kimColor.swift

Use switch for matching the color and UIColor

view Controller

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

var chosenColor: KimColor!

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return colorArray.count
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let resultViewController = segue.destination as! ResultViewController
resultViewController.chosenColor = chosenColor
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
chosenColor = KimColor(rawValue:indexPath.row)!

performSegue(withIdentifier: "PushToResultViewController", sender: nil)
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let rowData = colorArray[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "BasicCell", for: indexPath)
cell.textLabel?.text = rowData
cell.textLabel?.font = UIFont(name:"Menlo", size:22)
cell.textLabel?.textAlignment = .center

//https://stackoverflow.com/questions/37518214/how-to-change-the-color-of-text-in-a-tableview-swift

let backgroundView = UIView()
backgroundView.backgroundColor = KimColor(rawValue: indexPath.row)!.getUIColor()
cell.selectedBackgroundView = backgroundView
return cell
}

@IBOutlet weak var myTableView: UITableView!
let colorArray = ["Blue","Green","Red","Yellow","Violt","Brown","Black","Grey"]

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.

myTableView.delegate = self
myTableView.dataSource = self
}
}

I saw this page for When button pressed change the color

Peter`s medium

the outfit I saw this medium

If you like to whole project, you can visit my Git-hub

Haha🤣

--

--