Add a notification bell
Initialize the bell view
let bottomBellView = VFNotificationBellView(settings: settings, loginDelegate: self, onBellClicked: { [weak self] userUUID in
guard let strongSelf = self else {
return
}
let profileVC = VFProfileViewController.new(userUUID: userUUID, presentationType: .feed, loginDelegate: strongSelf, settings: settings)
strongSelf.present(profileVC, animated: true)
})
Add it on a UINavigationBar
bellView.widthAnchor.constraint(equalToConstant: 40).isActive = true
bellView.heightAnchor.constraint(equalToConstant: 40).isActive = true
self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: bellView)
Add it floating-mode
view.addSubview(bellView)
bellView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true
bellView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -20).isActive = true
bellView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true
bellView.topAnchor.constraint(equalTo: view.topAnchor, constant: -20).isActive = true
Set theme
In case your app has a light/dark mode setting, you can customize the look of the bell view with the following method
bellView.setTheme(.dark)
Updated 11 months ago