     // MARK: - UIView
     
     override func layoutSubviews() {
+        updateBackgroundsIfNeeded()
         updateViewIfNeeded()
         super.layoutSubviews()
     }
-
+    
+    override func draw(_ rect: CGRect) {
+        super.draw(rect)
+        updateShadowIfNeeded()
+    }
+    
 }
+
+fileprivate extension Dictionary {
+    
+    mutating func setValueOrRemoveNil(_ valueOrNil: Value?, forKey key: Key) {
+        if let value = valueOrNil {
+            self[key] = value
+        } else {
+            self.removeValue(forKey: key)
+        }
+    }
+    
+}
+
+fileprivate extension UIView {
+    
+    func apply(shadow: NSShadow?) {
+        if let shadowColor = shadow?.shadowColor as? UIColor {
+            layer.shadowColor = shadowColor.cgColor
+        }
+        layer.shadowRadius = shadow?.shadowBlurRadius ?? 0.0
+        layer.shadowOffset = shadow?.shadowOffset ?? CGSize.zero
+        layer.shadowOpacity = shadow != nil ? 1.0 : 0.0
+        layer.masksToBounds = shadow == nil
+    }
+    
+}

            } else {
                frame = drawing.intrinsicFrame
            }
            let icon = BFWDrawView(frame: frame)
            icon.drawing = drawing
            icon.tintColor = tintColor
            icon.contentMode = .redraw

        }
    }

    
    func makeIconDrawViews(from stateNameDict: [NSNumber: String], styleKit: String) {
        iconDrawViewForStateDict.removeAll()
        for (stateNumber, drawingName) in stateNameDict {
            if let drawing = BFWStyleKit.drawing(forStyleKitName: styleKit, drawingName: drawingName) {
                let icon = DrawingView(frame: drawing.intrinsicFrame)
                icon.drawing = drawing
                icon.tintColor = tintColor
                icon.contentMode = .redraw
                setIconDrawView(icon, for: UIControlState(rawValue: stateNumber.uintValue))
            }
        }
    }
    
    func makeBackgroundDrawViews(from stateNameDict: [NSNumber: String], styleKit: String) {
        backgroundDrawViewForStateDict.removeAll()
        for (stateNumber, drawingName) in stateNameDict {
            let background = DrawingView(frame: self.bounds)
            background.name = drawingName
            background.styleKit = styleKit
            background.contentMode = .redraw
            setBackgroundDrawView(background,
                for: UIControlState(rawValue: stateNumber.uintValue))
        }
    }


    // MARK: - UpdateView
    
    private func setNeedsUpdateView() {
