Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a title to HHFloatingViewButton #7

Open
alexisbar opened this issue Sep 12, 2019 · 9 comments
Open

Add a title to HHFloatingViewButton #7

alexisbar opened this issue Sep 12, 2019 · 9 comments

Comments

@alexisbar
Copy link

Hello,

Thanks for this great repo.
I'de like to add a title to each of the options in the menu.
I tried to modify the setupUI() and updateUI() but they're not displaying. Any idea ?

@alexisbar
Copy link
Author

Ok I found it. My image was way too big so it was taking all the uibutton frame.

Do you want me to do a pull request with this feature ?

@hemangshah
Copy link
Owner

@alexisbar , thanks for the kind words. Hope this repo will help you in your work. I will be happy to receive your pull-request on it. If you need any help while doing it - feel free to write me here and I will look into it asap.

@hemangshah
Copy link
Owner

@alexisbar - Few points to note with that pull-request:

  1. Please add a [String] - in file HHFloatingViewConfiguration.swift - optionTitles with that, if it's not empty, we will create title labels then.

  2. To keep difference, we will require a label file - create one like HHFloatingViewButton.swift - so we can find-out the title labels whenever requires.

  3. probably, you'll need to look into setupUI() to add titles.

There will be other parts you may require to update accordingly.

@krutitrivedi
Copy link

hello, i have tried to add label but does not display can you please share steps write down to SetupUI()

@hemangshah
Copy link
Owner

hemangshah commented Feb 27, 2020 via email

@krutitrivedi
Copy link

hello i tried to write code and add label file also but only static label show does not coordinate with other buttons

@hemangshah
Copy link
Owner

hemangshah commented Feb 27, 2020 via email

@krutitrivedi
Copy link

[write down this code to UpdateUI() 
fileprivate var optionsNew = [HHFloatingViewLabel]()
 fileprivate func updateUI() {
        handlerButton?.backgroundColor = configurations.handlerColor
        handlerButton?.setImage(configurations.handlerImage, for: .normal)

        for (index, optionButton) in options.enumerated() {
            optionButton.backgroundColor = configurations.optionColors[index]
            optionButton.setImage(configurations.optionImages[index], for: .normal)
        }
        
        for (index, optionLabel) in optionsNew.enumerated() {
            optionLabel.backgroundColor = configurations.optionColors[index]
            
        }
}
//setupUI
fileprivate func setupUI() {
        let superView = self.superview!

        let optionButton = HHFloatingViewButton()
        
        optionButton.backgroundColor = configurations.handlerColor
       optionButton.setImage(configurations.handlerImage, for: .normal)
        optionButton.addTarget(self, action: #selector(actionOpenOrCloseOptionsView), for: .touchUpInside)
        optionButton.frame = CGRect.init(origin: CGPoint.zero, size: configurations.handlerSize)
        self.dropShadow(onView: optionButton, withRadius: optionButton.layer.cornerRadius, withColor: optionButton.backgroundColor!.cgColor, isHandlerButton: true)
        superView.addSubview(optionButton)
        optionButton.center = self.center
        handlerButton = optionButton
        
        let optionLabel = HHFloatingViewLabel()
        
        optionLabel.isUserInteractionEnabled = false
        optionLabel.numberOfLines = 1
        optionLabel.font = .systemFont(ofSize: UIFont.systemFontSize)
        optionLabel.backgroundColor = UIColor.red
    
        optionLabel.frame = CGRect.init(origin: CGPoint(x: 100, y: 599), size: CGSize(width: 200, height: 50))
        optionLabel.text = "Kruti"
        superView.addSubview(optionLabel)
      //  optionLabel.center = self.center
          
        
        if configurations.showScaleAnimation {
            scaleAnimateButton(button: handlerButton, scaleValue: 0.0)
        }

        for index in 0..<configurations.numberOfOptions {
            let optionButton = HHFloatingViewButton()
            optionButton.backgroundColor = configurations.optionColors[index]
            optionButton.setImage(configurations.optionImages[index], for: .normal)
            optionButton.tag = (index + 1)
            optionButton.alpha = 0.0
            optionButton.addTarget(self, action: #selector(actionOptionsTapped), for: .touchUpInside)
            optionButton.frame = CGRect.init(origin: CGPoint.zero, size: configurations.optionsSize)
            self.dropShadow(onView: optionButton, withRadius: optionButton.layer.cornerRadius, withColor: optionButton.backgroundColor!.cgColor, isHandlerButton: false)
            superView.addSubview(optionButton)
            optionButton.center = self.center
            options.append(optionButton)
            
            
            let optionlabel = HHFloatingViewLabel()
            optionlabel.backgroundColor = configurations.optionColors[index]
            
            optionButton.tag = (index + 1)
            optionButton.alpha = 0.0
          
            optionButton.frame = CGRect.init(origin: CGPoint.zero, size: configurations.optionsSize)
            self.dropShadow(onView: optionButton, withRadius: optionlabel.layer.cornerRadius, withColor: optionlabel.backgroundColor!.cgColor, isHandlerButton: false)
            superView.addSubview(optionlabel)
            optionlabel.center = self.center
            optionsNew.append(optionLabel)
            
            
           
            
            
        }](url
![Screenshot 2020-02-27 at 3 01 25 PM](https://user-images.githubusercontent.com/28212734/75431257-9a69f300-5972-11ea-91a9-65eab0a96139.png)
)

@hemangshah
Copy link
Owner

hemangshah commented Feb 28, 2020

@krutitrivedi after looking at the code, I understand that, lots of re-work is necessary to show title along with the options. Unfortunately I don't have much time at this moment. If it's high priority for you, you have to look into by your self.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants