Day 15: No Sleep + UISwitch Fun

October 14, 2015 Will Lam

Had an amazing morning with Morning Reset by Camp Reset and dancing my butt off from 7:30 to 9:30 am after practically getting zero hours of sleep due to some personal stuff swirling through my head endlessly.. but I digress.

Went through a bunch of work and hit my limit, but learned a lot. The big thing that was learned today involved using something I’ve never used until today, UISwitch.

In addition to this stuff, I went through exercises playing around with range operators and logical operators in Playgrounds.

Anyway. Here’s the app (assets provided by Bitfountain):

UISwitch App Bitfountain

import UIKit

class ViewController: UIViewController {

  @IBOutlet weak var demoSwitch: UISwitch!
  @IBOutlet weak var switchStateLabel: UILabel!
  override func viewDidLoad() {
    // Do any additional setup after loading the view, typically from a nib.
    view.backgroundColor = UIColor(patternImage: UIImage(named: "UISwitchBackground")!)
    print("the initial value of the switch is \(demoSwitch.on)")

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

  @IBAction func changeSwitchTapped(sender: UIButton) {
    let yellow = UIColor(red: 255/255, green: 209/255, blue: 77/255, alpha: 1)
    let brown = UIColor(red: 108/255, green: 76/255, blue: 73/255, alpha: 1)
    if demoSwitch.on {
      demoSwitch.onTintColor = yellow
      demoSwitch.thumbTintColor = UIColor(red: 87/255, green: 175/255, blue: 63/255, alpha: 1)
    else {
      demoSwitch.tintColor = brown
      demoSwitch.thumbTintColor = brown

  @IBAction func demoSwitchTapped(sender: UISwitch) {
    print("The switch was tapped, now it is: \(demoSwitch.on)")
    let purple = UIColor(red: 189.255, green: 81/255, blue: 222/255, alpha: 1)
    sender.thumbTintColor = purple

Previous Article
Caught in the undertow
Caught in the undertow

So without having to go into any detail. A bomb was dropped in my life that ripped apart my personal life. ...

Next Article
Day 14: Kind of back on track and yet another tip calculator app…
Day 14: Kind of back on track and yet another tip calculator app…

So this past weekend was a bit worrisome in terms of keeping up with the challenge. Without getting into th...