Daltron / NotificationBanner

The easiest way to display highly customizable in app notification banners in iOS
MIT License
4.76k stars 659 forks source link

FloatingNotificationBanner missing on recently release 2.4.0? #216

Closed rigaldamez closed 5 years ago

rigaldamez commented 5 years ago

Hi,

regarding #213

image

Daltron commented 5 years ago

Hi @rigaldamez! I plan on fixing this tomorrow. Sorry for the inconvenience. Stay tuned!

Daltron commented 5 years ago

This has been fixed in the 2.4.1 Cocoapods release!

rigaldamez commented 5 years ago

thanks Daltron, how can I load a custom view within FloatingNotificationBanner?

image

Daltron commented 5 years ago

That currently isn't possible as FloatingNotificationBanner doesn't inherit from NotificationBanner which is the only class that supports custom views. This definitely needs to be added though. I have created an issue to track this.

Daltron commented 5 years ago

@rigaldamez, this can now be found in the 2.5.0 CocoaPods release!

rigaldamez commented 5 years ago

finally got a chance to test this and its not working for me... do I need to set the corner radius?

let banner = FloatingNotificationBanner(customView: myCustomView)
banner.show()
Daltron commented 5 years ago

You will need to set the cornerRadius when calling the show() method like so: show(cornerRadius: 10)

rigaldamez commented 5 years ago

I'm scratching my head, this is my code and the output is still square corners?

image

image

Daltron commented 5 years ago

Simulator Screen Shot - iPhone 8 Plus - 2019-07-22 at 20 52 45

Can you show me what your custom view consists of and how you are initializing it. I'm not seeing any issues.

rigaldamez commented 5 years ago

Initialising myCustomView and displaying using FloatingNotificationBanner

let imageData:NSData = NSData(contentsOf: imageUrl)!

                                DispatchQueue.main.async {

                                    let image = UIImage(data: imageData as Data)

                                    let myCustomView = NotificationBannerReply()

                                    myCustomView.contentView.backgroundColor = #colorLiteral(red: 0.8745098039, green: 0.3019607843, blue: 0.4117647059, alpha: 1)
                                    myCustomView.clinkBtnView.isHidden = false

                                    myCustomView.userSelectedId = toId
                                    myCustomView.venueId = venueId
                                    myCustomView.nameLbl.text = name
                                    myCustomView.profileImg.image = image
                                    myCustomView.messageLbl.text = "Acknowledged your compliment"

                                    //Banner
                                    let banner = FloatingNotificationBanner(customView: myCustomView)

                                    banner.autoDismiss = false
                                    banner.dismissOnTap = true
                                    banner.dismissOnSwipeUp = true

                                    banner.show(cornerRadius: 10)

                                    //Then remove from firebase once banner message has been shown
                                    let ref = self.REF_USERS_COMPLIMENTS_ACK.child(uid).child(complimentId)
                                    ref.removeValue()

                                }//end DispatchQueue.main.async

This is my NotificationBannerReply

class NotificationBannerReply: UIView {

    @IBOutlet var contentView: UIView!
    @IBOutlet weak var profileImg: CircleImage!
    @IBOutlet weak var nameLbl: UILabel!
    @IBOutlet weak var messageLbl: UILabel!
    @IBOutlet weak var clinkBtnView: DropShadowCircleView!

    var userSelectedId: String?
    var venueId: String?

    //taptic
    let tapticGenerator = UINotificationFeedbackGenerator()

    override init(frame: CGRect) {
        super.init(frame: frame)
        loadViewFromXib()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        loadViewFromXib()
    }

    func loadViewFromXib() {

        Bundle.main.loadNibNamed("NotificationBannerReply", owner: self, options: nil)
        addSubview(contentView)
        contentView.frame = self.bounds
        contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

    }
}
Daltron commented 5 years ago

I believe the problem is your loading your contentView from a xib and adding it as a subview. There is no workaround for this right now. You will need to set the cornerRadius of the contentView yourself in the xib or via code in this class. It should work then. 👍

rigaldamez commented 5 years ago

that worked!

Thanks so much for your support and for the great work you've put in to make this library available for us learners to use :)