d
This commit is contained in:
@@ -11,7 +11,7 @@ extension AppDelegate {
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
window?.rootViewController = Main.VC()
|
||||
window?.rootViewController = Main.Core()
|
||||
window?.makeKeyAndVisible()
|
||||
|
||||
return true
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import UIKit
|
||||
|
||||
// MARK: - Ядро-VC
|
||||
|
||||
extension Main {
|
||||
class VC: UIViewController {
|
||||
class Core: UIViewController {
|
||||
var buttons = [UIButton]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
@@ -10,6 +12,7 @@ extension Main {
|
||||
view.backgroundColor = .white
|
||||
|
||||
Main.Section16Buttons.setupCore(self)
|
||||
Main.SectionGrid.setupCore(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
21
iOS/src/Main.Section16Buttons.swift
Normal file
21
iOS/src/Main.Section16Buttons.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
import UIKit
|
||||
|
||||
// MARK: - Протоколы
|
||||
|
||||
protocol MainSection16Buttons { }
|
||||
|
||||
// MARK: - Реализация
|
||||
|
||||
extension Main {
|
||||
enum Section16Buttons {
|
||||
static func setupCore(_ core: Main.Core) {
|
||||
// Создаём 16 кнопок.
|
||||
for i in 0..<16 {
|
||||
let btn = UIButton()
|
||||
btn.tag = i
|
||||
core.view.addSubview(btn)
|
||||
core.buttons.append(btn)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
iOS/src/Main.SectionGrid.swift
Normal file
25
iOS/src/Main.SectionGrid.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
import UIKit
|
||||
|
||||
// MARK: - Протоколы
|
||||
|
||||
protocol MainSectionGrid { }
|
||||
|
||||
// MARK: - Реализация
|
||||
|
||||
extension Main {
|
||||
enum SectionGrid {
|
||||
static func setupCore(_ core: Main.Core) {
|
||||
let side = 50
|
||||
let space = 20
|
||||
let gap = side + space
|
||||
|
||||
// Расставляем кнопки в сетке 4x4.
|
||||
for btn in core.buttons {
|
||||
let id = btn.tag
|
||||
let row = Int(id / 4)
|
||||
btn.frame = CGRect(x: gap + (id - row * 4) * gap, y: gap + row * gap, width: side, height: side)
|
||||
btn.backgroundColor = .blue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import UIKit
|
||||
|
||||
// MARK: - Протоколы
|
||||
|
||||
protocol MainSection16Buttons {
|
||||
}
|
||||
|
||||
// MARK: - Реализация
|
||||
|
||||
extension Main {
|
||||
enum Section16Buttons {
|
||||
static func setupCore(_ core: Main.VC) {
|
||||
// Создаём 16 кнопок.
|
||||
for i in 0..<16 {
|
||||
let btn = UIButton()
|
||||
core.buttons.append(btn)
|
||||
btn.tag = i
|
||||
//????btn.addTarget(self, action: #selector(selectButton), for: .touchUpInside)
|
||||
core.view.addSubview(btn)
|
||||
}
|
||||
|
||||
// Расставляем их в сетке 4x4.
|
||||
for btn in core.buttons {
|
||||
btn.frame = CGRect(x: 0, y: btn.tag * 60, width: 50, height: 50)
|
||||
btn.backgroundColor = .blue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user