Hello,
Thanks for the wonderfull proyect. How add target action to popupItem buttons, for example when I touch pause button execute action in class DemoMusicPlayerController?.
Regards.
These are UIBarButtonItems, so:
self.popupPlayButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "pause-small"), style: .plain, target: self, action: #selector(playPauseAction(_:)))
self.popupPlayButtonItem?.tintColor = UIColor.black
self.popupNextButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "next-small"), style: .plain, target: self, action: #selector(next(_:)))
self.popupNextButtonItem?.tintColor = UIColor.black
self.popupItem.rightBarButtonItems = [popupPlayButtonItem!, popupNextButtonItem!]
Yes, as @iDevelopper says.
Thanks Leo and iDevelopper its works 馃憤
Leo, how change popupCloseButton?
Change to what?
other image or more customizable
If you want a custom button, set the system button style to none and put a button of your own that calls closePopup.
closePopup(animated: true, completion: nil) . not dismiss popup
I think it will be useful to add a LNPopupCloseButtonStyleCustom case as we can't replace the chevron class by another custom button.
Why not? You can place you own button wherever you want on the content view or popup content view controller. A custom dismiss button is just a button you can add already, so there is no point.
@iDevelopper do you have a example for that?
If you want a custom chevron, I have this library: https://github.com/LeoNatan/LNChevronView
I try close popup with this
@IBAction func didCloseButton(_ sender: UIButton) {
closePopup(animated: true, completion: nil)
}
not works.
You need to call closePopup on the correct view controller (the one you presented on).
@LeoNatan , I think @MaurixFx would like to have this:
tabBarController?.popupContentView.popupCloseButtonStyle = .custom
tabBarController?.popupContentView.popupCloseButton.setImage(#imageLiteral(resourceName: "Dismiss"), for: .normal)
extension DemoAlbumTableViewController: DemoMusicPlayerControllerDelegate {
func didClosePopup(sender: DemoMusicPlayerController) {
tabBarController?.closePopup(animated: true, completion: nil)
}
}
its works. Thanks :D
@iDevelopper Achieving this with UIButton is very easy. I don鈥檛 see a reason to complicate the framework鈥檚 code.
It would be interesting for positioning, constraints and all the others properties relatives to this button. The user of the library just have to chose an image for the button...
Hi @LeoNatan and @iDevelopper. I'm sorry for being here again asking, how can I detect when the pop up appears?.
Regards.
I need see know when popupBar appears beacuse actually Play music in the end of method didSelectRowAt, but the popupBar appears after the music play
tabBarController?.presentPopupBar(withContentViewController: popupContentController, animated: true, completion: nil)
tabBarController?.popupContentView.popupCloseButtonStyle = .round
tabBarController?.popupBar.tintColor = UIColor(white: 38.0 / 255.0, alpha: 1.0)
tabBarController?.popupBar.imageView.layer.cornerRadius = 5
tabBarController?.popupBar.backgroundStyle = .extraLight
popupContentController.listUrl = listURL
popupContentController.rowSelected = indexPath.row
AudioPlayerManager.shared.play(urlStrings: listURL, at: indexPath.row)
Use the completion block:
tabBarController?.presentPopupBar(withContentViewController: popupContentController, animated: true, completion: {
// Presented
// ...
})
Most helpful comment
These are UIBarButtonItems, so: