CustomView

class CustomView : UIView

The class is a subclass of UIView and is used in the bifocal display as the sideViews. It includes methods to draw the daily glucose ranges calculated using the member data and to draw the upper band for the background ‘safe’ range.

  • CGFloat containing the maximum glucose measurement for that day.

    Declaration

    Swift

    var dailyHigh: CGFloat
  • CGFloat containing the minimum glucose measurement for that day.

    Declaration

    Swift

    var dailyLow: CGFloat
  • CGFloat containing the mean average of the glucose measurements for that day.

    Declaration

    Swift

    var avgArrayValue: CGFloat
  • The init method is called on the instantiation of a CustomView. It initializes the member variables to 0 which is used to determine if there is any data stored for this CustomView.

    • Paramater frame: CGRect, the bounds of the View.
    • Paramater dailyHigh: CGFloat, the maximum glucose reading for the day.

    Declaration

    Swift

    init(frame: CGRect, dailyHigh: CGFloat)
  • This is an override method from the superclass and is called when the CustomView is created by the ViewController. It calls methods which draw the ‘safe’ region onto the view. It also sets the visibility of the CustomView depending on if the CustomView has data stored in it.

    • Paramater rect: CGRect, the bounds of the CustomView.

    Declaration

    Swift

    override func draw(_ rect: CGRect)
  • Creates a rectangle of colour White from the mid-point of the CustomView (~10 on graph to ~4) to create the ‘safe’ region.

    Declaration

    Swift

    private func colourMiddleBand()
  • Creates a rectangle with a size of the top half of the CustomView giving the top band (between 10 and 20 on the graph).

    Declaration

    Swift

    private func colourTopBand()
  • Method used to draw the glucose range bar and create the mark for the average glucose measurement. It uses a UIBezierPath for the range and average. It is able to do this accurately due to the relative size nature of the CustomView.

    Declaration

    Swift

    private func drawRangeBar()