Skip to main content
質問文の書式を整えてみました
ソース リンク
supa
  • 5,399
  • 4
  • 18
  • 41
     myImageA = UIColor.redColor();
     myImageB = UIColor.greenColor();
     myImageC = UIColor.blueColor();
     myImageE = UIColor.yellowColor();
    

    myImageView.backgroundColor = myImageD
    myImageView2.backgroundColor = myImageD
    myImageView3.backgroundColor = myImageD
    myImageView4.backgroundColor = myImageD
    myImageView5.backgroundColor = myImageD
    myImageView6.backgroundColor = myImageD
    
    myImageView8.backgroundColor = myImageD
    myImageView9.backgroundColor = myImageD
    myImageView10.backgroundColor = myImageD
    myImageView11.backgroundColor = myImageD
    myImageView12.backgroundColor = myImageD
    myImageView13.backgroundColor = myImageD
     myImageView14.backgroundColor = myImageD
    myImageView15.backgroundColor = myImageD
    myImageView16.backgroundColor = myImageD

    myImageViewa.backgroundColor = myImageD
    myImageView2a.backgroundColor = myImageD
    myImageView3a.backgroundColor = myImageD
    myImageView4a.backgroundColor = myImageD
    myImageView5a.backgroundColor = myImageD
    myImageView6a.backgroundColor = myImageD
    myImageView7a.backgroundColor = myImageD
    myImageView8a.backgroundColor = myImageD
    myImageView9a.backgroundColor = myImageD
    myImageView10a.backgroundColor = myImageD
    myImageView12a.backgroundColor = myImageD
    myImageView14a.backgroundColor = myImageD
    myImageView13a.backgroundColor = myImageD
    myImageView15a.backgroundColor = myImageD
    myImageView16a.backgroundColor = myImageD
    
    myImageViewb.backgroundColor = myImageD
    myImageView2b.backgroundColor = myImageD
    myImageView3b.backgroundColor = myImageD
    myImageView4b.backgroundColor = myImageD
    myImageView5b.backgroundColor = myImageD
    myImageView6b.backgroundColor = myImageD
    myImageView7b.backgroundColor = myImageD
    myImageView8b.backgroundColor = myImageD
    myImageView9b.backgroundColor = myImageD
    myImageView10b.backgroundColor = myImageD
    myImageView11b.backgroundColor = myImageD
    myImageView13b.backgroundColor = myImageD
    myImageView14b.backgroundColor = myImageD
    myImageView15b.backgroundColor = myImageD
    myImageView16b.backgroundColor = myImageD
    
    
    myImageView2c.backgroundColor = myImageD
    myImageView3c.backgroundColor = myImageD
    myImageView4c.backgroundColor = myImageD
    myImageView5c.backgroundColor = myImageD
    myImageView6c.backgroundColor = myImageD
    myImageView7c.backgroundColor = myImageD
    myImageView8c.backgroundColor = myImageD
    myImageView9c.backgroundColor = myImageD
    myImageView10c.backgroundColor = myImageD
    myImageView11c.backgroundColor = myImageD
    myImageView12c.backgroundColor = myImageD
    myImageView13c.backgroundColor = myImageD
    myImageView14c.backgroundColor = myImageD
    myImageView15c.backgroundColor = myImageD
    myImageView16c.backgroundColor = myImageD
    
    
    
    
    
    
}



func onClickMyButton(sender: UIButton){
    
    
    myImageD = myImageA
    
    
    }


func onClickMyButton2(sender: UIButton){
    
    myImageD = myImageB
        
    }
    

func onClickMyButton3(sender: UIButton){
    
    myImageD = myImageC
    
}

func onClickMyButton4(sender: UIButton){
    
    myImageD = myImageE
    
}


override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    let touch = touches.first as UITouch?
    
    if let touchedImageView = touch!.view as? UIImageView {
        
        touchedImageView.backgroundColor = myImageD
       
       
    }
    
    


}






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

}

         myImageA = UIColor.redColor();
         myImageB = UIColor.greenColor();
         myImageC = UIColor.blueColor();
         myImageE = UIColor.yellowColor();
        
  
        myImageView.backgroundColor = myImageD
        myImageView2.backgroundColor = myImageD
        myImageView3.backgroundColor = myImageD
        myImageView4.backgroundColor = myImageD
        myImageView5.backgroundColor = myImageD
        myImageView6.backgroundColor = myImageD
        
        myImageView8.backgroundColor = myImageD
        myImageView9.backgroundColor = myImageD
        myImageView10.backgroundColor = myImageD
        myImageView11.backgroundColor = myImageD
        myImageView12.backgroundColor = myImageD
        myImageView13.backgroundColor = myImageD
         myImageView14.backgroundColor = myImageD
        myImageView15.backgroundColor = myImageD
        myImageView16.backgroundColor = myImageD
   
        myImageViewa.backgroundColor = myImageD
        myImageView2a.backgroundColor = myImageD
        myImageView3a.backgroundColor = myImageD
        myImageView4a.backgroundColor = myImageD
        myImageView5a.backgroundColor = myImageD
        myImageView6a.backgroundColor = myImageD
        myImageView7a.backgroundColor = myImageD
        myImageView8a.backgroundColor = myImageD
        myImageView9a.backgroundColor = myImageD
        myImageView10a.backgroundColor = myImageD
        myImageView12a.backgroundColor = myImageD
        myImageView14a.backgroundColor = myImageD
        myImageView13a.backgroundColor = myImageD
        myImageView15a.backgroundColor = myImageD
        myImageView16a.backgroundColor = myImageD
        
        myImageViewb.backgroundColor = myImageD
        myImageView2b.backgroundColor = myImageD
        myImageView3b.backgroundColor = myImageD
        myImageView4b.backgroundColor = myImageD
        myImageView5b.backgroundColor = myImageD
        myImageView6b.backgroundColor = myImageD
        myImageView7b.backgroundColor = myImageD
        myImageView8b.backgroundColor = myImageD
        myImageView9b.backgroundColor = myImageD
        myImageView10b.backgroundColor = myImageD
        myImageView11b.backgroundColor = myImageD
        myImageView13b.backgroundColor = myImageD
        myImageView14b.backgroundColor = myImageD
        myImageView15b.backgroundColor = myImageD
        myImageView16b.backgroundColor = myImageD
        
        
        myImageView2c.backgroundColor = myImageD
        myImageView3c.backgroundColor = myImageD
        myImageView4c.backgroundColor = myImageD
        myImageView5c.backgroundColor = myImageD
        myImageView6c.backgroundColor = myImageD
        myImageView7c.backgroundColor = myImageD
        myImageView8c.backgroundColor = myImageD
        myImageView9c.backgroundColor = myImageD
        myImageView10c.backgroundColor = myImageD
        myImageView11c.backgroundColor = myImageD
        myImageView12c.backgroundColor = myImageD
        myImageView13c.backgroundColor = myImageD
        myImageView14c.backgroundColor = myImageD
        myImageView15c.backgroundColor = myImageD
        myImageView16c.backgroundColor = myImageD
        
        
        
        
        
        
    }
  
    
   
    func onClickMyButton(sender: UIButton){
        
        
        myImageD = myImageA
        
        
        }
    
    
    func onClickMyButton2(sender: UIButton){
        
        myImageD = myImageB
            
        }
        
    
    func onClickMyButton3(sender: UIButton){
        
        myImageD = myImageC
        
    }
    
    func onClickMyButton4(sender: UIButton){
        
        myImageD = myImageE
        
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch = touches.first as UITouch?
        
        if let touchedImageView = touch!.view as? UIImageView {
            
            touchedImageView.backgroundColor = myImageD
           
           
        }
        
        
    
    
    }
    
    
    
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
     myImageA = UIColor.redColor();
     myImageB = UIColor.greenColor();
     myImageC = UIColor.blueColor();
     myImageE = UIColor.yellowColor();
    

    myImageView.backgroundColor = myImageD
    myImageView2.backgroundColor = myImageD
    myImageView3.backgroundColor = myImageD
    myImageView4.backgroundColor = myImageD
    myImageView5.backgroundColor = myImageD
    myImageView6.backgroundColor = myImageD
    
    myImageView8.backgroundColor = myImageD
    myImageView9.backgroundColor = myImageD
    myImageView10.backgroundColor = myImageD
    myImageView11.backgroundColor = myImageD
    myImageView12.backgroundColor = myImageD
    myImageView13.backgroundColor = myImageD
     myImageView14.backgroundColor = myImageD
    myImageView15.backgroundColor = myImageD
    myImageView16.backgroundColor = myImageD

    myImageViewa.backgroundColor = myImageD
    myImageView2a.backgroundColor = myImageD
    myImageView3a.backgroundColor = myImageD
    myImageView4a.backgroundColor = myImageD
    myImageView5a.backgroundColor = myImageD
    myImageView6a.backgroundColor = myImageD
    myImageView7a.backgroundColor = myImageD
    myImageView8a.backgroundColor = myImageD
    myImageView9a.backgroundColor = myImageD
    myImageView10a.backgroundColor = myImageD
    myImageView12a.backgroundColor = myImageD
    myImageView14a.backgroundColor = myImageD
    myImageView13a.backgroundColor = myImageD
    myImageView15a.backgroundColor = myImageD
    myImageView16a.backgroundColor = myImageD
    
    myImageViewb.backgroundColor = myImageD
    myImageView2b.backgroundColor = myImageD
    myImageView3b.backgroundColor = myImageD
    myImageView4b.backgroundColor = myImageD
    myImageView5b.backgroundColor = myImageD
    myImageView6b.backgroundColor = myImageD
    myImageView7b.backgroundColor = myImageD
    myImageView8b.backgroundColor = myImageD
    myImageView9b.backgroundColor = myImageD
    myImageView10b.backgroundColor = myImageD
    myImageView11b.backgroundColor = myImageD
    myImageView13b.backgroundColor = myImageD
    myImageView14b.backgroundColor = myImageD
    myImageView15b.backgroundColor = myImageD
    myImageView16b.backgroundColor = myImageD
    
    
    myImageView2c.backgroundColor = myImageD
    myImageView3c.backgroundColor = myImageD
    myImageView4c.backgroundColor = myImageD
    myImageView5c.backgroundColor = myImageD
    myImageView6c.backgroundColor = myImageD
    myImageView7c.backgroundColor = myImageD
    myImageView8c.backgroundColor = myImageD
    myImageView9c.backgroundColor = myImageD
    myImageView10c.backgroundColor = myImageD
    myImageView11c.backgroundColor = myImageD
    myImageView12c.backgroundColor = myImageD
    myImageView13c.backgroundColor = myImageD
    myImageView14c.backgroundColor = myImageD
    myImageView15c.backgroundColor = myImageD
    myImageView16c.backgroundColor = myImageD
    
    
    
    
    
    
}



func onClickMyButton(sender: UIButton){
    
    
    myImageD = myImageA
    
    
    }


func onClickMyButton2(sender: UIButton){
    
    myImageD = myImageB
        
    }
    

func onClickMyButton3(sender: UIButton){
    
    myImageD = myImageC
    
}

func onClickMyButton4(sender: UIButton){
    
    myImageD = myImageE
    
}


override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    let touch = touches.first as UITouch?
    
    if let touchedImageView = touch!.view as? UIImageView {
        
        touchedImageView.backgroundColor = myImageD
       
       
    }
    
    


}






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

}

         myImageA = UIColor.redColor();
         myImageB = UIColor.greenColor();
         myImageC = UIColor.blueColor();
         myImageE = UIColor.yellowColor();
        
  
        myImageView.backgroundColor = myImageD
        myImageView2.backgroundColor = myImageD
        myImageView3.backgroundColor = myImageD
        myImageView4.backgroundColor = myImageD
        myImageView5.backgroundColor = myImageD
        myImageView6.backgroundColor = myImageD
        
        myImageView8.backgroundColor = myImageD
        myImageView9.backgroundColor = myImageD
        myImageView10.backgroundColor = myImageD
        myImageView11.backgroundColor = myImageD
        myImageView12.backgroundColor = myImageD
        myImageView13.backgroundColor = myImageD
         myImageView14.backgroundColor = myImageD
        myImageView15.backgroundColor = myImageD
        myImageView16.backgroundColor = myImageD
   
        myImageViewa.backgroundColor = myImageD
        myImageView2a.backgroundColor = myImageD
        myImageView3a.backgroundColor = myImageD
        myImageView4a.backgroundColor = myImageD
        myImageView5a.backgroundColor = myImageD
        myImageView6a.backgroundColor = myImageD
        myImageView7a.backgroundColor = myImageD
        myImageView8a.backgroundColor = myImageD
        myImageView9a.backgroundColor = myImageD
        myImageView10a.backgroundColor = myImageD
        myImageView12a.backgroundColor = myImageD
        myImageView14a.backgroundColor = myImageD
        myImageView13a.backgroundColor = myImageD
        myImageView15a.backgroundColor = myImageD
        myImageView16a.backgroundColor = myImageD
        
        myImageViewb.backgroundColor = myImageD
        myImageView2b.backgroundColor = myImageD
        myImageView3b.backgroundColor = myImageD
        myImageView4b.backgroundColor = myImageD
        myImageView5b.backgroundColor = myImageD
        myImageView6b.backgroundColor = myImageD
        myImageView7b.backgroundColor = myImageD
        myImageView8b.backgroundColor = myImageD
        myImageView9b.backgroundColor = myImageD
        myImageView10b.backgroundColor = myImageD
        myImageView11b.backgroundColor = myImageD
        myImageView13b.backgroundColor = myImageD
        myImageView14b.backgroundColor = myImageD
        myImageView15b.backgroundColor = myImageD
        myImageView16b.backgroundColor = myImageD
        
        
        myImageView2c.backgroundColor = myImageD
        myImageView3c.backgroundColor = myImageD
        myImageView4c.backgroundColor = myImageD
        myImageView5c.backgroundColor = myImageD
        myImageView6c.backgroundColor = myImageD
        myImageView7c.backgroundColor = myImageD
        myImageView8c.backgroundColor = myImageD
        myImageView9c.backgroundColor = myImageD
        myImageView10c.backgroundColor = myImageD
        myImageView11c.backgroundColor = myImageD
        myImageView12c.backgroundColor = myImageD
        myImageView13c.backgroundColor = myImageD
        myImageView14c.backgroundColor = myImageD
        myImageView15c.backgroundColor = myImageD
        myImageView16c.backgroundColor = myImageD
        
        
        
        
        
        
    }
  
    
   
    func onClickMyButton(sender: UIButton){
        
        
        myImageD = myImageA
        
        
        }
    
    
    func onClickMyButton2(sender: UIButton){
        
        myImageD = myImageB
            
        }
        
    
    func onClickMyButton3(sender: UIButton){
        
        myImageD = myImageC
        
    }
    
    func onClickMyButton4(sender: UIButton){
        
        myImageD = myImageE
        
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch = touches.first as UITouch?
        
        if let touchedImageView = touch!.view as? UIImageView {
            
            touchedImageView.backgroundColor = myImageD
           
           
        }
        
        
    
    
    }
    
    
    
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
本文に 95 文字追加
ソース リンク

保存する色が4つあるのでその分forkeyも4つ用意したほうがいいですか?
forkeyが1つだと保存した場所の色がすべて同じ色になってしまいませんか?

保存する色が4つあるのでその分forkeyも4つ用意したほうがいいですか?
forkeyが1つだと保存した場所の色がすべて同じ色になってしまいませんか?

本文に 15 文字追加
ソース リンク

下の4色はボタンになっています。(今度5色に増やす予定です。)
各色ボタンを押すごとにタッチしたマス目に押したボタンの色を反映できます。

下の4色はボタンになっています。
各色ボタンを押すごとにタッチしたマス目に押したボタンの色を反映できます。

下の4色はボタンになっています。(今度5色に増やす予定です。)
各色ボタンを押すごとにタッチしたマス目に押したボタンの色を反映できます。

ソース リンク
読み込んでいます