TheBestClockAlarmView

class TheBestClockAlarmView : UIControl

This is the view class for each alarm button. It is a button with a label in it. The label contains the alarm time and state.

It has a pulsing “snore” for sleeping.

  • Our delegate

    Declaration

    Swift

    weak var delegate: TheBestClockAlarmViewDelegate!
  • Which alarm this is. 0-based index.

    Declaration

    Swift

    var index: Int
  • This holds our state for the alarm we’re displaying.

    Declaration

    Swift

    var alarmRecord: TheBestClockAlarmSetting!
  • The name of the font to be used for the alarm display.

    Declaration

    Swift

    var fontName: String
  • The color to display the alarm.

    Declaration

    Swift

    var fontColor: UIColor!
  • The brightness to use for active alarm display.

    Declaration

    Swift

    var brightness: CGFloat
  • This is set to true while the Alarm Editor is up. It tells us to ignore the set brightness, and display an active alarm as 1.0.

    Declaration

    Swift

    var fullBright: Bool
  • This is the gesture recognizer we use to detect a long-press.

    Declaration

    Swift

    var longPressGestureRecognizer: UILongPressGestureRecognizer!
  • This is the size we want the display to be.

    Declaration

    Swift

    var desiredFontSize: CGFloat { get set }
  • This is the label object for the alarm.

    Declaration

    Swift

    @IBOutlet
    var displayLabel: UILabel!
  • Basic initializer.

    Declaration

    Swift

    init(   frame inFrame: CGRect = CGRect.zero,
            alarmRecord inAlarmRecord: TheBestClockAlarmSetting
        )

    Parameters

    frame

    The frame for the control.

    alarmRecord

    The alarm object to be associated with this button.

  • Coder initializer.

    Declaration

    Swift

    required init?(coder aDecoder: NSCoder)

    Parameters

    coder

    The coder that contains our state.

  • Called when we will lay out the subviews.

    We use this to set up most of our control state.

    Declaration

    Swift

    override func layoutSubviews()
  • The drawing routine. The display is rendered here.

    Declaration

    Swift

    override func draw(_ inRect: CGRect)

    Parameters

    inRect

    The rect in which the drawing is to be done.

  • Called as tracking starts.

    • with: The event for the touch. It is optional.

    Declaration

    Swift

    override func beginTracking(_ inTouch: UITouch, with inEvent: UIEvent?) -> Bool

    Parameters

    inTouch

    The current touch.

  • Called repeatedly as tracking continues.

    • with: The event for the touch. It is optional.

    Declaration

    Swift

    override func continueTracking(_ inTouch: UITouch, with inEvent: UIEvent?) -> Bool

    Parameters

    inTouch

    The current touch.

  • Called when tracking is done.

    • with: The event for the touch. It is optional.

    Declaration

    Swift

    override func endTracking(_ inTouch: UITouch?, with inEvent: UIEvent?)

    Parameters

    inTouch

    The current touch. It is optional.

  • Called to cancel tracking.

    Declaration

    Swift

    override func cancelTracking(with inEvent: UIEvent?)

    Parameters

    with

    The cancel event. It is optional.

  • Called upon a long press. We use this to open the Alarm Editor.

    Declaration

    Swift

    @IBAction
    func longPressGesture(_: UILongPressGestureRecognizer)
  • This animates a “snore.”

    This is a pulsing of brightness.

    Declaration

    Swift

    func snore()