         {
             if (self.isHighlighted)
             {
-                self.backgroundColor = _highlightedBackgroundColor
-                self.layer.borderColor = _highlightedBorderColor.cgColor
+                self.backgroundColor = self._highlightedBackgroundColor ?? self._normalBackgroundColor
+                self.layer.borderColor = self._highlightedBorderColor?.cgColor ?? self._normalBorderColor.cgColor
                 self.imageView?.tintColor = self.titleColor(for: .highlighted)
             }
             else if (self.isSelected)
             {
-                self.backgroundColor = _selectedBackgroundColor
-                self.layer.borderColor = _selectedBorderColor.cgColor
+                self.backgroundColor = self._selectedBackgroundColor ?? self._normalBackgroundColor
+                self.layer.borderColor = self._selectedBorderColor?.cgColor ?? self._normalBorderColor.cgColor
                 self.imageView?.tintColor = self.titleColor(for: .selected)
             }
             else
             {
-                self.backgroundColor = _normalBackgroundColor
-                self.layer.borderColor = _normalBorderColor.cgColor
+                self.backgroundColor = self._normalBackgroundColor
+                self.layer.borderColor = self._normalBorderColor.cgColor
                 self.imageView?.tintColor = self.titleColor(for: UIControlState())
             }
         }
         else
         {
-            self.backgroundColor = self._disabledBackgroundColor
-            self.layer.borderColor = self._disabledBorderColor.cgColor
+            self.backgroundColor = self._disabledBackgroundColor ?? self._normalBackgroundColor
+            self.layer.borderColor = self._disabledBorderColor?.cgColor ?? self._normalBorderColor.cgColor
             self.imageView?.tintColor = self.titleColor(for: .disabled)
         }
     }

    // MARK: Methods
    //
    // -----------------------------------------------------------------------------------------------------------------------
    
    // -----------------------------------------------------------
    //  UIButton overrides
    // -----------------------------------------------------------


open class ExtendedButton: UIButton {
    private var _normalBackgroundColor:UIColor = UIColor.black
    private var _highlightedBackgroundColor:UIColor?
    private var _selectedBackgroundColor:UIColor?
    private var _disabledBackgroundColor:UIColor?
    
    private var _normalBorderColor:UIColor = UIColor.clear
    private var _highlightedBorderColor:UIColor?
    private var _selectedBorderColor:UIColor?
    private var _disabledBorderColor:UIColor?
    
    
    
