Animal Trivia V1

animalTrivia

I built this quiz application but it really suck because i can build something much better but i want to start from the very beginning and go up straight 🙂 the app asks a question and display an image of the animal in question you will then have to choose the correct answer.

The menu implementation doesnt fit a standard ios application because i simple segue between three viewcontrollers which doesnt make any sense as have mentioned it is just a demo app and trying to build myself.

First ViewController code:


import UIKit

class ViewController: UIViewController {

 
 @IBOutlet weak var aLabel: UILabel!
 @IBOutlet weak var blabel: UILabel!
 @IBOutlet weak var clabel: UILabel!
 
 @IBOutlet weak var aButton: UIButton!
 @IBOutlet weak var bButton: UIButton!
 @IBOutlet weak var cButton: UIButton!
 
 @IBOutlet weak var incorrectAimage: UIImageView!
 @IBOutlet weak var incorrectBimage: UIImageView!
 @IBOutlet weak var correctBbutton: UIImageView!
 
 
 @IBAction func aButtonPressed(sender: AnyObject) {
 incorrectAimage.hidden = false
 aButton.hidden = true
 bButton.enabled = false
 cButton.enabled = false
 aLabel.textColor = UIColor(red: 0.98, green: 0.39, blue: 0.4, alpha: 1.0)
 
 }
 
 @IBAction func bButtonPressed(sender: AnyObject) {
 incorrectBimage.hidden = false
 bButton.hidden = true
 aButton.enabled = false
 cButton.enabled = false
 blabel.textColor = UIColor(red: 0.98, green: 0.39, blue: 0.4, alpha: 1.0)
 }
 
 @IBAction func cButtonPressed(sender: AnyObject) {
 correctBbutton.hidden = false
 cButton.hidden = true
 aButton.enabled = false
 bButton.enabled = false
 clabel.textColor = UIColor.greenColor()
 }
 
 
 override func viewDidLoad() {
 super.viewDidLoad()
 // Do any additional setup after loading the view, typically from a nib.
 }

 override func didReceiveMemoryWarning() {
 super.didReceiveMemoryWarning()
 // Dispose of any resources that can be recreated.
 }


}

Third ViewController:

import UIKit

class ThirdViewController: UIViewController {
 
 @IBOutlet weak var aButton: UIButton!
 @IBOutlet weak var aLabel: UILabel!
 
 @IBOutlet weak var bButton: UIButton!
 @IBOutlet weak var bLabel: UILabel!
 
 @IBOutlet weak var cButton: UIButton!
 @IBOutlet weak var cLabel: UILabel!
 
 @IBOutlet weak var startoverButton: UIButton!
 
 override func viewDidLoad() {
 super.viewDidLoad()

 // Do any additional setup after loading the view.
 startoverButton.layer.cornerRadius = 7.0

 }

 override func didReceiveMemoryWarning() {
 super.didReceiveMemoryWarning()
 // Dispose of any resources that can be recreated.
 }
 
 func disableButtons() {
 aButton.enabled = false
 bButton.enabled = false
 cButton.enabled = false
 }
 
 @IBAction func aButtonPressed(sender: AnyObject) {
 let incorrectAnswerImage = UIImage(named: "incorrectAnswer")
 aButton.setImage(incorrectAnswerImage, forState: UIControlState.Normal)
 aLabel.textColor = UIColor(red: 0.98, green: 0.39, blue: 0.4, alpha: 1.0)
 disableButtons()

 }

 @IBAction func bButtonPressed(sender: AnyObject) {
 let incorrectAnswerImage = UIImage(named: "incorrectAnswer")
 bButton.setImage(incorrectAnswerImage, forState: UIControlState.Normal)
 bLabel.textColor = UIColor(red: 0.98, green: 0.39, blue: 0.4, alpha: 1.0)
 disableButtons()
 }
 
 @IBAction func cButtonPressed(sender: AnyObject) {
 let correctAnswerImage = UIImage(named: "correctAnswer")
 cButton.setImage(correctAnswerImage, forState: UIControlState.Normal)
 cLabel.textColor = UIColor.greenColor()
 disableButtons()
 }
}

Second ViewController:

import UIKit

class SecondViewController: UIViewController {
 
 @IBOutlet weak var aButton: UIButton!
 @IBOutlet weak var incorrectAimage: UIImageView!
 @IBOutlet weak var aLabek: UILabel!
 
 @IBOutlet weak var bButton: UIButton!
 @IBOutlet weak var correctAnswer: UIImageView!
 @IBOutlet weak var bLabel: UILabel!
 
 @IBOutlet weak var cButton: UIButton!
 @IBOutlet weak var incorrectCanswer: UIImageView!
 @IBOutlet weak var cLabel: UILabel!
 
 

 override func viewDidLoad() {
 super.viewDidLoad()

 // Do any additional setup after loading the view.
 }

 override func didReceiveMemoryWarning() {
 super.didReceiveMemoryWarning()
 // Dispose of any resources that can be recreated.
 }
 
 

 
 @IBAction func aButtonPressed(sender: AnyObject) {
 aButton.hidden = true
 incorrectAimage.hidden = false
 bButton.enabled = false
 cButton.enabled = false
 aLabek.textColor = UIColor(red: 0.98, green: 0.39, blue: 0.4, alpha: 1.0)
 }
 
 @IBAction func bButtonPressed(sender: AnyObject) {
 bButton.hidden = true
 correctAnswer.hidden = false
 aButton.enabled = false
 cButton.enabled = false
 bLabel.textColor = UIColor.greenColor()
 }

 @IBAction func cButtonPressed(sender: AnyObject) {
 cButton.hidden = true
 incorrectCanswer.hidden = false
 aButton.enabled = false
 bButton.enabled = false
 cLabel.textColor = UIColor(red: 0.98, green: 0.39, blue: 0.4, alpha: 1.0)
 }
 

}
Animal Trivia V1

Blogging

swift_iOS_app_developers

I started this blog so i can work on my writing skills and mostly to focus on my skills am going to be blogging about ios and osx dev with swift and sharing my apps also steps i used in building them so stick around and enjoy 🙂

Blogging