Git Product home page Git Product logo

Comments (6)

lcolli98 avatar lcolli98 commented on July 22, 2024

I'm having the same issue ... did you find a fix @Harryjeffs ?

I tried
self.view.bringSubviewToFront(button2Image)
where button2Image is the image that the BadgeHub is attached to. Same behaviour as you reported.

from badgehub.

Harryjeffs avatar Harryjeffs commented on July 22, 2024

@lcolli98 Hey! I posted to stackoverflow, and found the answer myself - https://stackoverflow.com/questions/61298622/uicollectionviewcell-badge-masked-behind-view.

Issue was how I was rounding the corners. Let me know if this helps you too :)

from badgehub.

lcolli98 avatar lcolli98 commented on July 22, 2024

That isn't working for me ... any ideas?

button2Image is a UIImageView on top of a UIButton, button2. The badge is being appended to the image view. I've tried manually changing the Z position, ensuring it is first in the storyboard, and bringSubviewToFront, but still no luck.

The image view doesn't have rounded corners (the button does, but the badge should easily be contained within the button).

from badgehub.

Harryjeffs avatar Harryjeffs commented on July 22, 2024

@lcolli98 Mind sharing some code so we can help debug?

from badgehub.

lcolli98 avatar lcolli98 commented on July 22, 2024
@IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var button1: UIButton!
    @IBOutlet weak var button2: UIButton!
    @IBOutlet weak var button2Image: UIImageView!
    @IBOutlet weak var button3: UIButton!
    @IBOutlet weak var button4: UIButton!
    @IBOutlet weak var userAccButton: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Set the title text based on whether logged in or not
        /*
         if (loggedIn) {
            titleLabel.text = "Welcome back, <name>"
         } else {
            titleLabel.text = "Welcome to AeroBuddy"
         }
         */
        
        // Setup user account button
        userAccButton.layer.cornerRadius = 0.5 * userAccButton.bounds.size.width
        userAccButton.clipsToBounds = true
        userAccButton.layer.borderWidth = 2
        userAccButton.layer.borderColor = UIColor.lightGray.withAlphaComponent(0.6).cgColor
        
        // Set the news notifcation bubble - see https://iosexample.com/a-way-to-quickly-add-a-notification-badge-icon-to-any-view/
        // Use newsBubble.increment(), newsBubble.decerement(), newsBubble.setCount(newCount: Int) to control
        self.view.bringSubviewToFront(button2Image)
        let newsBubble = BadgeHub(view: button2Image)
        if (false /* no unread news */) {
            newsBubble.setCount(0)
        } else {
            // Set the amount of unread news articles
            newsBubble.setCount(1)
            //self.view.bringSubviewToFront(button2Image)
            newsBubble.bump()
        }
    }

image
That's the view controller where everything is displayed.

from badgehub.

lcolli98 avatar lcolli98 commented on July 22, 2024

For anyone else with this issue ... I added a transparent UIView over the top of the button and added the BadgeHub to that. This works.

from badgehub.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.