-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathPhotoCancelItem.swift
59 lines (48 loc) · 1.34 KB
/
PhotoCancelItem.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
//
// PhotoCancelItem.swift
// Pods
//
// Created by BAO HA on 4/12/24.
//
import HXPhotoPicker
import UIKit
extension UIView: HXPickerCompatible {
var size: CGSize {
get { frame.size }
set {
var rect = frame
rect.size = newValue
frame = rect
}
}
}
public class PhotoCancelItem: UIView, PhotoNavigationItem {
public weak var itemDelegate: PhotoNavigationItemDelegate?
public var itemType: PhotoNavigationItemType { .cancel }
let config: PickerConfiguration
public required init(config: PickerConfiguration) {
self.config = config
super.init(frame: .zero)
initView()
}
var button: UIButton!
func initView() {
button = UIButton(type: .custom)
button.setImage(UIImage.close, for: .normal)
button.addTarget(self, action: #selector(didCancelClick), for: .touchUpInside)
addSubview(button)
if let btnSize = button.currentImage?.size {
button.size = btnSize
size = btnSize
}
}
@objc
func didCancelClick() {
print("close ne")
itemDelegate?.photoControllerDidCancel()
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}