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

Change Color of Cancel and Done Buttons #326

Open
kherlopian2 opened this issue Jan 29, 2017 · 4 comments
Open

Change Color of Cancel and Done Buttons #326

kherlopian2 opened this issue Jan 29, 2017 · 4 comments

Comments

@kherlopian2
Copy link

Am using swift 3:

ActionSheetStringPicker.show(withTitle: "Select Status", rows: pickerData, initialSelection: self.selectedStatusRow, doneBlock: {
picker, value, index in
self.selectedStatusRow = value
return
}, cancel: { ActionStringCancelBlock in return }, origin: sender)

I want to change the color of done and cancel, to my globaltint color.How can I do that in swift 3? Thank You for this library.

I created the issue on http://stackoverflow.com/questions/41925687/actionsheetstringpicker-change-button-color as well

@warisappify
Copy link

warisappify commented Feb 1, 2017

I solved it by using following code

 @IBAction func selectFieldsClicked(_ sender : UIButton){
        let cancelButton = getBarButton("Cancel")        
        let doneButton = getBarButton("Done")
        let acp = ActionSheetStringPicker(title: "Title", rows: [your rows list], initialSelection: 0, doneBlock: { (picker : ActionSheetStringPicker?, selectedIndex : Int, selectedItem : Any?) in
                
            }, cancel: { (picker : ActionSheetStringPicker?) in
                
            }, origin: sender)

    acp!.setCancelButton(cancelButton)
    acp!.setDoneButton(doneButton)
    acp!.show()
}


func getBarButton(_ title : String) -> UIBarButtonItem{
        let customButton =  UIButton.init(type: UIButtonType.custom)
        customButton.setTitle(title, for: .normal)
        customButton.roundCorner(5)
        customButton.frame = CGRect.init(x: 0, y: 5, width: 80, height: 32)
        customButton.backgroundColor = UIColor.greenColor
    
        return UIBarButtonItem.init(customView: customButton)
}

@douglas-srs
Copy link

What about the title? How to change it's color?

@douglas-srs
Copy link

douglas-srs commented May 24, 2017

Got it, you can customize anything with this:

let picker = ActionSheetMultipleStringPicker(title: "Title", rows: [
                myRows,
                ], initialSelection: [0], doneBlock: {
                    picker, indexes, values in                   
                    return
            }, cancel: { ActionMultipleStringCancelBlock in return }, origin: self)
picker?.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]//this is actually the title of toolbar
picker?.toolbarButtonsColor = UIColor.blue
picker?.pickerBackgroundColor = UIColor.gray
picker?.toolbarBackgroundColor = UIColor.white
picker?.setTextColor(UIColor.whiter)//this is the color of the picker view items
picker?.show()

@hechukwu
Copy link

hechukwu commented Aug 2, 2020

picker?.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white] doesn't seem to change the title color

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

No branches or pull requests

4 participants