Nightonke / VHBoomMenuButton

A menu which can ... BOOM! - iOS
MIT License
582 stars 112 forks source link

How to add number badge label for BoomButton #5

Open anhkieet opened 7 years ago

anhkieet commented 7 years ago

Hi Nightonke. Have a nice day.

Could you show me how to add number badge label for BoomButton. Many thanks 👍

Nightonke commented 7 years ago

Hey. Do you mean adding a label to the sub-buttons(boom-button)? Currently there is not a convenient way to achieve that. But you can try this method of BMB:

    /// Get the boom-button at index. Notice that the boom-buttons may not be created by BMB, so this method may return nil.
    ///
    /// - Parameter index: Index.
    /// - Returns: The boom-button at the given index, may be nil.
    public func boomButton(at index: Int) -> BoomButton? {
        if 0 <= index && index < boomButtons.count {
            return boomButtons[index]
        }
        return nil
    }

You can get the boom-button after booming(must at this time because the boom-buttons may not be created), then add a custom-views and animations to each boom-button.

anhkieet commented 7 years ago

@Nightonke I have hamburger button (BoomButton) on navigation bar. And I have 3 sub-buttons (settings, chat, ranking). I want to show number unread message in chat button when tapping hamburger button :)