配列を使ってすっきりしたいです。
お世話になっております。
現在アプリを開発中ですが、何しろ知識がないため、いろいろなところでつまずいています。
今回の質問は、下記のコード(同じことを25回繰り返します)を配列(Arrayなど)を使ってすっきりとさせたいことです。
一行つづ書いていけば一応完成はするのですが、ビルドして走らせてみると、このページだげ、動きがカクカクしていてスムーズに動きません。
コードがすっきりすればカクカクもなくなるとおもいます。
ググッて見てあれこれと試してはいますが、なかなか動いてくれません。
よろしくお願いします。
btn2 = UIButton() btn3 = UIButton() btn4 = UIButton() btn5 = UIButton() btn6 = UIButton() btn7 = UIButton() btn8 = UIButton() btn9 = UIButton() btn10 = UIButton() btn11 = UIButton() btn12 = UIButton() btn13 = UIButton() btn14 = UIButton() btn15 = UIButton() btn16 = UIButton() btn17 = UIButton() btn18 = UIButton() btn19 = UIButton() btn20 = UIButton() btn21 = UIButton() btn22 = UIButton() btn23 = UIButton() btn24 = UIButton() btn25 = UIButton() btn1.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn2.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn3.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn4.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn5.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn6.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn7.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn8.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn9.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn10.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn11.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn12.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn13.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn14.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn15.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn16.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn17.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn18.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn19.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn20.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn21.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn22.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn23.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn24.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn25.frame = CGRectMake(0,0,buttonWidth,buttonHeight) btn1.layer.masksToBounds = true btn2.layer.masksToBounds = true btn3.layer.masksToBounds = true btn4.layer.masksToBounds = true btn5.layer.masksToBounds = true btn6.layer.masksToBounds = true btn7.layer.masksToBounds = true btn8.layer.masksToBounds = true btn9.layer.masksToBounds = true btn10.layer.masksToBounds = true btn11.layer.masksToBounds = true btn12.layer.masksToBounds = true btn13.layer.masksToBounds = true btn14.layer.masksToBounds = true btn15.layer.masksToBounds = true btn16.layer.masksToBounds = true btn17.layer.masksToBounds = true btn18.layer.masksToBounds = true btn19.layer.masksToBounds = true btn20.layer.masksToBounds = true btn21.layer.masksToBounds = true btn22.layer.masksToBounds = true btn23.layer.masksToBounds = true btn24.layer.masksToBounds = true btn25.layer.masksToBounds = true btn1.layer.cornerRadius = 2.0 btn2.layer.cornerRadius = 2.0 btn3.layer.cornerRadius = 2.0 btn4.layer.cornerRadius = 2.0 btn5.layer.cornerRadius = 2.0 btn6.layer.cornerRadius = 2.0 btn7.layer.cornerRadius = 2.0 btn8.layer.cornerRadius = 2.0 btn9.layer.cornerRadius = 2.0 btn10.layer.cornerRadius = 2.0 btn11.layer.cornerRadius = 2.0 btn12.layer.cornerRadius = 2.0 btn13.layer.cornerRadius = 2.0 btn14.layer.cornerRadius = 2.0 btn15.layer.cornerRadius = 2.0 btn16.layer.cornerRadius = 2.0 btn17.layer.cornerRadius = 2.0 btn18.layer.cornerRadius = 2.0 btn19.layer.cornerRadius = 2.0 btn20.layer.cornerRadius = 2.0 btn21.layer.cornerRadius = 2.0 btn22.layer.cornerRadius = 2.0 btn23.layer.cornerRadius = 2.0 btn24.layer.cornerRadius = 2.0 btn25.layer.cornerRadius = 2.0