-
Notifications
You must be signed in to change notification settings - Fork 0
/
Colors.swift
52 lines (45 loc) · 1.35 KB
/
Colors.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
//
// SwiftUIView.swift
// LearnApp
//
// Created by Ahmadxon Qodirov on 23/06/24.
//
import SwiftUI
import UIKit
struct Colors: View {
let rect = RoundedRectangle(cornerSize: CGSize(width: 20, height: 20))
var body: some View {
ZStack{
rect
.fill(
//Color.primary
//Color(UIColor.systemGreen)
Color(.init(red: 0, green: 0.32, blue: 0.57, alpha: 1))
)
.frame(width: 300, height: 200)
VStack{
Text("Hello, world")
Text("Hello, world2")
Button("Tap me", action: {
rect
.fill(Color(uiColor: .systemGreen))
print("helloworld")
})
}
}
}
}
#Preview {
Colors()
}
class MyView: UIViewController {
let color = UIHostingController(rootView: Colors())
override func viewDidLoad() {
super.viewDidLoad()
//view.backgroundColor = .white
view.addSubview(color.view)
color.view.translatesAutoresizingMaskIntoConstraints = false
color.view.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
color.view.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
}
}