-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmudikVC.swift
executable file
·124 lines (93 loc) · 4.34 KB
/
mudikVC.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import SwiftUI
struct ContentView5: View {
var body: some View {
gameBeginView()
}
}
struct gameBeginView3 : UIViewControllerRepresentable {
typealias UIViewControllerType = UINavigationController
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
}
func makeUIViewController(context: Context) -> UIViewControllerType {
let navController = UINavigationController (rootViewController: SecondVC())
return navController
}
}
class mudikVC : UIViewController {
var imageGirl = UIImage(named: "girl")
var imageGirlView : UIImageView!
var imageBoy = UIImage (named: "boy")
var imageBoyView = UIImageView ()
var textIntroDialogue = UILabel ()
var startGameButton = UIButton ()
var bubleIMage = UIImage (named: "bubleGirl")
var bubleImageView : UIImageView!
var mudikImage = UIImage (named: "car2")
var mudikView : UIImageView!
var nextButton = UIButton ()
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.isHidden = true
assignbackground()
// Do any additional setup after loading the view.
}
func assignbackground(){
let background = UIImage(named: "peta")
var imageView : UIImageView!
imageView = UIImageView(frame: view.bounds)
imageView.contentMode = UIView.ContentMode.scaleAspectFill
imageView.clipsToBounds = true
imageView.image = background
imageView.center = view.center
view.addSubview(imageView)
self.view.sendSubviewToBack(imageView)
setupView()
}
func setupView () {
mudikView = UIImageView ()
mudikView.translatesAutoresizingMaskIntoConstraints = false
mudikView.image = mudikImage
view.addSubview(mudikView)
NSLayoutConstraint.activate([
mudikView.topAnchor.constraint(equalTo: view.topAnchor, constant: 674),
mudikView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 346),
mudikView.widthAnchor.constraint(equalToConstant: 142),
mudikView.heightAnchor.constraint(equalToConstant: 80)
])
startGameButton = UIButton ()
startGameButton.setTitle("Drive", for: .normal)
startGameButton.translatesAutoresizingMaskIntoConstraints = false
startGameButton.backgroundColor = .systemBlue
startGameButton.layer.cornerRadius = 5
view.addSubview(startGameButton)
NSLayoutConstraint.activate([
startGameButton.topAnchor.constraint(equalTo: view.topAnchor, constant: 1080),
startGameButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 600),
startGameButton.widthAnchor.constraint(equalToConstant: 100),
startGameButton.heightAnchor.constraint(equalToConstant: 50)
])
startGameButton.addTarget(self, action: #selector(actionTerbanginRocket), for: .touchUpInside)
nextButton = UIButton ()
nextButton.setTitle("Next", for: .normal)
nextButton.translatesAutoresizingMaskIntoConstraints = false
nextButton.backgroundColor = .systemBlue
nextButton.layer.cornerRadius = 5
view.addSubview(nextButton)
NSLayoutConstraint.activate([
nextButton.topAnchor.constraint(equalTo: view.topAnchor, constant: 1080),
nextButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 720),
nextButton.widthAnchor.constraint(equalToConstant: 100),
nextButton.heightAnchor.constraint(equalToConstant: 50)
])
nextButton.addTarget(self, action: #selector(nextVC), for: .touchUpInside)
}
@objc func actionTerbanginRocket() {
UIView.animate(withDuration: 5.0, delay: 0) {
self.mudikView.frame.origin.x = 36
self.mudikView.frame.origin.y = 447
}
}
@objc func nextVC() {
navigationController?.pushViewController(arriveVC(), animated: true)
}
}