PopupInfoViewController.swift
3.88 KB
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
//
// PopupInfoViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 16/10/24.
//
import UIKit
class PopupInfoViewController: UIViewController {
@IBOutlet weak var containerView: UIView!
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var headerCloseButton: UIButton!
@IBOutlet weak var infoLabel: UILabel!
@IBOutlet weak var submitButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Add arrow programmatically
let arrowSize = CGSize(width: 15, height: 7.5) // Width and height of the arrow
let arrowView = ArrowView(frame: CGRect(
x: (popupView.frame.width - arrowSize.width - 35),
y: popupView.frame.minY - arrowSize.height,
width: arrowSize.width,
height: arrowSize.height))
containerView.addSubview(arrowView)
// containerView.bringSubviewToFront(popupView)
// Add shadow
containerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.57).cgColor
containerView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
containerView.layer.shadowOpacity = 1.0
containerView.layer.shadowRadius = 20.0
containerView.layer.masksToBounds = false
containerView.backgroundColor = .clear
popupView.backgroundColor = UIColor(rgb: 0xE6E6E6)
popupView.layer.cornerRadius = 14
headerLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
headerLabel.textColor = UIColor(rgb: 0x212121)
headerLabel.text = "SUPERMARKET DEALS"
headerCloseButton.setImage(UIImage(named: "ic_close_3.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
headerCloseButton.imageView?.layer.transform = CATransform3DMakeScale(1.3, 1.3, 1.3)
infoLabel.font = UIFont(name: "PeridotPE-Regular", size: 16.0)
infoLabel.textColor = UIColor(rgb: 0x212121)
infoLabel.text = "Δημιούργησε το δικό σου ενιαίο κουπόνι προσφορών, και εξαργύρωσέ το στα supermarket της επιλογής σου γρήγορα και εύκολα με ένα μόνο κωδικό κουπονιού!"
submitButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 14)
submitButton.setTitle("Τέλος", for: .normal)
submitButton.setTitleColor(UIColor(rgb: 0x212121), for: .normal)
submitButton.frame.size.width = submitButton.intrinsicContentSize.width
}
// MARK: - Actions
@IBAction func headerCloseButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
@IBAction func submitButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
}
class ArrowView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .clear
}
required init?(coder: NSCoder) {
super.init(coder: coder)
self.backgroundColor = .clear
}
override func draw(_ rect: CGRect) {
// Set up the context
guard let context = UIGraphicsGetCurrentContext() else { return }
// Set the arrow color (can adjust as needed)
context.setFillColor(UIColor(rgb: 0xE6E6E6).cgColor)
// Create the arrow's path (a triangle)
let path = UIBezierPath()
path.move(to: CGPoint(x: rect.width / 2, y: 0)) // Arrow top
path.addLine(to: CGPoint(x: rect.width, y: rect.height)) // Bottom right
path.addLine(to: CGPoint(x: 0, y: rect.height)) // Bottom left
path.close() // Close the triangle
// Fill the arrow shape
context.addPath(path.cgPath)
context.fillPath()
}
}