CPCDayCellRenderer

public protocol CPCDayCellRenderer

A type that is able to render a cell of a month view, representing an arbitrary day.

  • drawCell(in:) Default implementation

    Fully renders content of cell, representing a specific day. Default implementation calls drawCellBackground (in:) and drawCellTitle (in:), in that order.

    Note

    Graphical context is guaranteed to be cleared and than filled with background color for CPCDayCellState.normal inside cell’s frame.

    Important

    Drawing code is not restricted by cell frame (e. g. graphical context is not clipped to this rect) but doing so may lead to undesired consequences. For example, border cells are implicitly clipped at some of their edges because redraw context does perform clipping that matches redrawn area.

    Important

    Cell separators drawing code is called after cell content drawing code, so you shouldn’t worry that you can accidentally mess them up. Area under separators is not cleared before drawing so they do blend with anything that was drawn inside a cell.

    Default Implementation

    Declaration

    Swift

    func drawCell(in context: Context)

    Parameters

    context

    Cell rendering context.

  • drawCellBackground(in:) Default implementation

    Renders background of a day cell. Default implementation calls drawCellBackground (state:color:frame:in:) with corresponding values of context.

    Default Implementation

    Declaration

    Swift

    func drawCellBackground(in context: Context)

    Parameters

    context

    Cell rendering context.

  • drawCellTitle(in:) Default implementation

    Renders title of a day cell. Default implementation calls drawCellTitle (title:attributes:frame:in:) with corresponding values of context.

    Default Implementation

    Declaration

    Swift

    func drawCellTitle(in context: Context)

    Parameters

    context

    Cell rendering context.

  • Context Extension method

    Declaration

    Swift

    public typealias Context = CPCDayCellRenderingContext
  • Default implementation of day cell background drawing. Fills frame of context with color if state != CPCDayCellState.normal.

    Declaration

    Swift

    public func drawCellBackground(state: CPCDayCellState, color: UIColor?, frame: CGRect, in context: CGContext)

    Parameters

    state

    Cell state.

    color

    Target background color.

    frame

    Cell frame.

    context

    Graphics context to draw in.

  • Default implementation of day cell title drawing. Renders title with attributes in frame of context.

    Declaration

    Swift

    public func drawCellTitle(title: NSString, attributes: NSDictionary, frame: CGRect, in context: CGContext)

    Parameters

    title

    Cell title (day number).

    attributes

    Cell title attributes, e.g. foreground color or font.

    frame

    Cell title target frame.

    context

    Graphics context to draw in.