--

Swift 九九乘法App/Multiplication Table App

The following is a Multiplication Table App that I created with Swift in Xcode.

The following is my codes of the App interface.

I added the Title “Multiplication Table”at the top and an image and at the bottom of the interface separately other than the codes.

import UIKitclass ViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.let width = view.frame.width / 10var x: CGFloat = 0for i in 0…9{print(x)var y: CGFloat = widthlet label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “X”} else {label.text = “\(i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 2let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “1”} else {label.text = “\(i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 3let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “2”} else {label.text = “\(2 * i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 4let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “3”} else {label.text = “\(3 * i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 5let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “4”} else {label.text = “\(4 * i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 6let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “5”} else {label.text = “\(5 * i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 7let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “6”} else {label.text = “\(6 * i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 8let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “7”} else {label.text = “\(7 * i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 9let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “8”} else {label.text = “\(8 * i)”}view.addSubview(label)x = x + width}x = 0for i in 0…9{print(x)var y: CGFloat = width * 10let label = UILabel(frame: CGRect(x: x, y: y, width: width, height: width))if i == 0 {label.text = “9”} else {label.text = “\(9 * i)”}view.addSubview(label)x = x + width}}}

--

--