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

SimpleButton doesn't call configureButtonStyles when used in InterfaceBuilder #12

Closed
gunterhager opened this issue Jun 3, 2016 · 0 comments · Fixed by #13
Closed

SimpleButton doesn't call configureButtonStyles when used in InterfaceBuilder #12

gunterhager opened this issue Jun 3, 2016 · 0 comments · Fixed by #13

Comments

@gunterhager
Copy link
Contributor

The button doesn't appear as expected when subclassed and used with @IBInspectable variables to set up the values for configureButtonStyles like here:

import UIKit
import SimpleButton

@IBDesignable

class DesignableButton: SimpleButton {

        /// Background color for normal state.
    @IBInspectable var backgroundColorNormal: UIColor?
    @IBInspectable var backgroundColorHighlight: UIColor?
    @IBInspectable var titleColorNormal: UIColor?
    @IBInspectable var titleColorHighlighted: UIColor?

    @IBInspectable var shadow: Bool = false
    @IBInspectable var shadowColor: UIColor?
    @IBInspectable var shadowOffset: CGSize = CGSizeZero
    @IBInspectable var shadowRadius: CGFloat = 0
    @IBInspectable var shadowOpacity: Float = 0

    override func configureButtonStyles() {
        super.configureButtonStyles()

        if let backgroundColorNormal = backgroundColorNormal {
            setBackgroundColor(backgroundColorNormal, forState: .Normal)
        }
        if let backgroundColorHighlight = backgroundColorHighlight {
            setBackgroundColor(backgroundColorHighlight, forState: .Highlighted)
        }
        if let titleColorNormal = titleColorNormal {
            setTitleColor(titleColorNormal, forState: .Normal)
        }
        if let titleColorHighlighted = titleColorHighlighted {
            setTitleColor(titleColorHighlighted, forState: .Highlighted)
        }

        if shadow {
            if let shadowColor = shadowColor {
                setShadowColor(shadowColor)
            }
            setShadowOffset(shadowOffset)
            setShadowRadius(shadowRadius)
            setShadowOpacity(shadowOpacity)
        }
    }


}
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

Successfully merging a pull request may close this issue.

1 participant