Swift UIKit側でtap、SwiftUI側に通知
記事「Swift SwiftUI上でUIKit使用、アプリバッググランド遷移をUIKit側に通知、Combineにしてみた」の逆
tap契機に通知
準備
extension Notification.Name {
static let tapMonthlyCalendar = Notification.Name("example.tapMonthlyCalendar")
}
UIKit側
: let tap = UITapGestureRecognizer(target: self, action: #selector(self.tap(sender:))) tap.numberOfTapsRequired = 1 self.view.addGestureRecognizer(tap) :
SwiftUI側
.onReceive(NotificationCenter.default.publisher(for: .tapMonthlyCalendar, object: nil), perform: { _ in
print("tapMonthlyCalendar")
})







