 @IBDesignable
 public class EZClockView: UIView {
     
+    private var faceView: UIView = UIView()
     private var handHours: UIView = UIView()
-    private var faceView: UIView = UIView()
     private var handMinutes: UIView = UIView()
     private var handSeconds: UIView = UIView()
     
-    @IBInspectable public var faceBackgroundColor: UIColor = UIColor.whiteColor()
+    private var sideLength: CGFloat = 0
+    
+    // MARK: Time
+    @IBInspectable public var hours: Int = 0 { didSet { updateHands() } }
+    @IBInspectable public var minutes: Int = 0 { didSet { updateHands() } }
+    @IBInspectable public var seconds: Int = 0 { didSet { updateHands() } }
+    
+    // MARK: Face
+    @IBInspectable public var faceBackgroundColor: UIColor = UIColor.whiteColor() { didSet { faceView.backgroundColor = faceBackgroundColor } }
     @IBInspectable public var faceBorderColor: UIColor = UIColor.blackColor()
     @IBInspectable public var faceBorderWidth: CGFloat = 2.0
     
-    @IBInspectable public var hours: Int = 0 { didSet { setTime(h: hours, m: minutes, s: seconds) } }
-    @IBInspectable public var minutes: Int = 0 { didSet { setTime(h: hours, m: minutes, s: seconds) } }
-    @IBInspectable public var seconds: Int = 0 { didSet { setTime(h: hours, m: minutes, s: seconds) } }
+    // MARK: Hour hand
+    @IBInspectable public var hoursColor: UIColor = UIColor.blackColor() { didSet { handHours.backgroundColor = hoursColor } }
+    @IBInspectable public var hoursLength: CGFloat = 0.5 {
+        didSet { setupHand(handHours, lengthRatio: hoursLength, thickness: hoursThickness, offset: hoursOffset) }
+    }
+    @IBInspectable public var hoursThickness: CGFloat = 4 {
+        didSet { setupHand(handHours, lengthRatio: hoursLength, thickness: hoursThickness, offset: hoursOffset) }
+    }
+    @IBInspectable public var hoursOffset: CGFloat = 2 {
+        didSet { setupHand(handHours, lengthRatio: hoursLength, thickness: hoursThickness, offset: hoursOffset) }
+    }
     
-    @IBInspectable public var hoursColor: UIColor = UIColor.blackColor()
-    @IBInspectable public var hoursLength: CGFloat = 0.5
-    @IBInspectable public var hoursThickness: CGFloat = 4
-    @IBInspectable public var hoursOffset: CGFloat = 2
+    // MARK: Minute hand
+    @IBInspectable public var minutesColor: UIColor = UIColor.blackColor() { didSet { handMinutes.backgroundColor = minutesColor } }
+    @IBInspectable public var minutesLength: CGFloat = 0.7 {
+        didSet { setupHand(handMinutes, lengthRatio: minutesLength, thickness: minutesThickness, offset: minutesOffset) }
+    }
+    @IBInspectable public var minutesThickness: CGFloat = 2 {
+        didSet { setupHand(handMinutes, lengthRatio: minutesLength, thickness: minutesThickness, offset: minutesOffset) }
+    }
+    @IBInspectable public var minutesOffset: CGFloat = 2 {
+        didSet { setupHand(handMinutes, lengthRatio: minutesLength, thickness: minutesThickness, offset: minutesOffset) }
+    }
     
-    @IBInspectable public var minutesColor: UIColor = UIColor.blackColor()
-    @IBInspectable public var minutesLength: CGFloat = 0.7
-    @IBInspectable public var minutesThickness: CGFloat = 2
-    @IBInspectable public var minutesOffset: CGFloat = 2
+    // MARK: Second hand
+    @IBInspectable public var secondsColor: UIColor = UIColor.redColor() { didSet { handSeconds.backgroundColor = secondsColor } }
+    @IBInspectable public var secondsLength: CGFloat = 0.8 {
+        didSet { setupHand(handSeconds, lengthRatio: secondsLength, thickness: secondsThickness, offset: secondsOffset) }
+    }
+    @IBInspectable public var secondsThickness: CGFloat = 1 {
+        didSet { setupHand(handSeconds, lengthRatio: secondsLength, thickness: secondsThickness, offset: secondsOffset) }
+    }
+    @IBInspectable public var secondsOffset: CGFloat = 2 {
+        didSet { setupHand(handSeconds, lengthRatio: secondsLength, thickness: secondsThickness, offset: secondsOffset) }
+    }
     
-    @IBInspectable public var secondsColor: UIColor = UIColor.redColor()
-    @IBInspectable public var secondsLength: CGFloat = 0.8
-    @IBInspectable public var secondsThickness: CGFloat = 1
-    @IBInspectable public var secondsOffset: CGFloat = 2
+    // MARK: Public methods
+    public func setTime(#h: Int, m: Int, s: Int, animated: Bool = false) {
+        hours = h
+        minutes = m
+        seconds = s
+        updateHands(animated: animated)
+    }
     
-    private var sideLength: CGFloat = 0
+    public func setTime(date: NSDate, animated: Bool = false) {
+        let components = NSCalendar.currentCalendar().components((.HourCalendarUnit | .MinuteCalendarUnit | .SecondCalendarUnit), fromDate: date)
+        hours = components.hour
+        minutes = components.minute
+        seconds = components.second
+        updateHands(animated: animated)
+    }
     
     public override func layoutSubviews() {
         super.layoutSubviews()

        sideLength = min(self.bounds.size.width, self.bounds.size.height)
        
        // Reset all transforms
        setuphand(handHours, lengthRatio: hoursLength, thickness: hoursThickness, offset: hoursOffset)
        setuphand(handMinutes, lengthRatio: minutesLength, thickness: minutesThickness, offset: minutesOffset)
        setuphand(handSeconds, lengthRatio: secondsLength, thickness: secondsThickness, offset: secondsOffset)
        
        handHours.backgroundColor = hoursColor
        handMinutes.backgroundColor = minutesColor

        hand.frame = CGRectMake(centerInParent.x-(thickness/2), centerInParent.y - handLength + offset, thickness, handLength)
    }
    
    private func updateHands(animated: Bool = false) {
        // Put everything in seconds to have ratios
        let hoursInSeconds = (hours%12)*3600
        let minutesInSeconds = (minutes%60)*60
        let secondsInSeconds = (seconds%60)
        
        let hoursRatio = CGFloat(hoursInSeconds + minutesInSeconds + secondsInSeconds) / 43200.0
        let minutesRatio = CGFloat(minutesInSeconds + secondsInSeconds) / 3600.0
        let secondsRatio = CGFloat(secondsInSeconds) / 60.0
        
        if (animated) {
            UIView.animateWithDuration(0.3) {
                self.handSeconds.transform = CGAffineTransformMakeRotation(CGFloat(2*M_PI)*secondsRatio)
                self.handMinutes.transform = CGAffineTransformMakeRotation(CGFloat(2*M_PI)*minutesRatio)
                self.handHours.transform = CGAffineTransformMakeRotation(CGFloat(2*M_PI)*hoursRatio)
            }
        } else {
            handSeconds.transform = CGAffineTransformMakeRotation(CGFloat(2*M_PI)*secondsRatio)
            handMinutes.transform = CGAffineTransformMakeRotation(CGFloat(2*M_PI)*minutesRatio)
            handHours.transform = CGAffineTransformMakeRotation(CGFloat(2*M_PI)*hoursRatio)
        }
    }
}
