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

Unable to customize UIButton. #21

Closed
HackShitUp opened this issue Dec 13, 2017 · 3 comments
Closed

Unable to customize UIButton. #21

HackShitUp opened this issue Dec 13, 2017 · 3 comments

Comments

@HackShitUp
Copy link

I've been trying to modify the AZDialogView's buttons to make them look like the default iOS alert controllers (with a button image in it), but with the gesture-dismissing capabilities of this project. But, I can't customize the button for some reason. Here's my code:

// Configure UIButton styles
        dialogController.buttonStyle = { (button, height, position) in
            // Fill button with color
            button.setImage(UIImage(named: "pop"), for: .normal)
            button.semanticContentAttribute = .forceLeftToRight
            button.titleLabel?.font = UIFont(name: "AvenirNext-Demibold", size: 16)
            button.layer.masksToBounds = true
        }
@Minitour
Copy link
Owner

@HackShitUp Thanks for bringing up the issue. At the moment the buttons are initialized using the UIButton class without any special sub-classing capabilities. I will add a new property in the future to allow using custom UIButton sub classes.

Add this line to remove the border:

button.layer.borderColor = UIColor.clear.cgColor

@HackShitUp
Copy link
Author

@Minitour awesome, thanks a lot

@Minitour
Copy link
Owner

@HackShitUp I added some new APIs in version 1.2.1.
One of them is called buttonInit, a closure that allows you to use a custom UIButton sub-class.

Example:

dialog.buttonInit = { index in
    //set a custom button only for the first index
    return index == 0 ? HighlightableButton() : nil
}

If a nil value is returned then the default button that was used in the previous versions of the framework will be created.

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

2 participants