Skip to content

Theme values don't affect menu title color #12

@revblaze

Description

@revblaze

Hi,

First off, huge fan of the project! Best menu option for iOS that I've seen by far.

This may be a me problem, but I've been trying to create a dark theme based on your struct layout in MenuTheme.swift. For whatever reason, the menu title (UILabel) won't respect the set UIColor.

I see that, in MenuView.swift, you have the following setup:

public func applyTheme(_ theme: MenuTheme) {
        self.theme = theme
        
        titleLabel.font = theme.font
        titleLabel.textColor = theme.darkTintColor
        gestureBarView.backgroundColor = theme.gestureBarTint
        tintView.backgroundColor = theme.backgroundTint
        effectView.effect = theme.blurEffect
        
        contents?.applyTheme(theme)
    }
    
    public override func tintColorDidChange() {
        titleLabel.textColor = tintColor
    }
}

The title label should always reflect either theme.darkTintColor (or alternatively, tintColor), correct?

I have the following set for my custom dark theme (in MenuTheme.swift):

public struct DarkMenuTheme: MenuTheme {
    
    public let font = UIFont.systemFont(ofSize: 16, weight: .medium)
    public let textColor = UIColor.white
    public let brightTintColor = UIColor.white
    public let darkTintColor = UIColor.white
    public let highlightedTextColor = UIColor.white
    public let highlightedBackgroundColor = UIColor(red: 0/255.0, green: 122/255.0, blue: 255/255.0, alpha: 1.0)
    public let backgroundTint = UIColor(white: 0.0, alpha: 0.15)
    public let gestureBarTint = UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 0.7)
    public let blurEffect = UIBlurEffect(style: .dark)
    public let shadowColor = UIColor.black
    public let shadowOpacity: Float = 0.3
    public let shadowRadius: CGFloat = 7.0
    public let separatorColor = UIColor(white: 1, alpha: 0.1)
    
    public init() {}
}

However, regardless of what I do, the menu title will appear as UIColor.black (or something very similar) – as opposed to the set UIColor.white value. When I select the menu title, it will turn white; however, at rest (non-interaction), it remains dark and I'm unable to change it without changing the core code.

Similarly, do you plan on adding the other three layout options to your project? ie. Menu dropdown to:

  • Down, Right
  • Down, Left
  • Up, Right
  • Up, Left

Thank you again for the project! It added such an elegant beauty to my simple web browser project.

EDIT: Also, are you planning on adding disabled menu options? ie. When a user can't go back in a WKWebView, disabling the "Back" menu option.

EDIT 2: Since SF Symbols were released relatively recently, is there any possibility of adding those as a menu title or adding an SF glyph next to the left of a menu item? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions