//
//  ViewController.swift
//  uiLabel_color
//
//  Created by yoshiyuki oshige on 2015/08/27.
//  Copyright © 2015年 yoshiyuki oshige. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var myLabel1: UILabel!
    @IBOutlet weak var myLabel2: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // myLabel1に入っている数値
        let num = Double(myLabel1.text!)
        // 文字色と背景色の設定
        if num >= 0 {
            myLabel1.textColor = UIColor.blackColor()
            myLabel1.backgroundColor = UIColor.whiteColor()
        } else {
            myLabel1.textColor = UIColor.whiteColor()
            myLabel1.backgroundColor = UIColor.redColor()
        }
        
        // myLabel1の背景色と同じ色にする
        myLabel2.textColor = myLabel1.backgroundColor
        
    }

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


}

