PhamBaTho / BTNavigationDropdownMenu

The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when a user clicks on the navigation title.
MIT License
2.69k stars 411 forks source link

Create subtitle! (successfully) #103

Closed rayastar closed 7 years ago

rayastar commented 7 years ago
  1. add subtitle label to BTNavigationDropdownMenu.swift: fileprivate var subTitle: UILabel!

  2. Create label:

    let width  = titleSize.width + (self.configuration.arrowPadding + self.configuration.arrowImage.size.width)*2
    let height = self.navigationController!.navigationBar.frame.height
    let frameForSubTitle = CGRect(x: 0, y: 14, width: width, height: height)
    
    self.subTitle = UILabel(frame: frameForSubTitle)
    self.subTitle.text = items[0] as! String
    self.subTitle.textColor = self.menuTitleColor
    self.subTitle.font = UIFont(name: "Avenir-Heavy", size: 10)
    self.subTitle.textAlignment = .center
    self.menuButton.addSubview(self.subTitle)
  3. Edit : func setMenuTitle(_ title: String) { self.subTitle.text = title }

Result:

ezgif com-1967279614