CPCDayCellRenderer
public protocol CPCDayCellRenderer
A type that is able to render a cell of a month view, representing an arbitrary day.
-
drawCell(in:)
Default implementationFully renders content of cell, representing a specific day. Default implementation calls
drawCellBackground (in:)
anddrawCellTitle (in:)
, in that order.Note
Graphical context is guaranteed to be cleared and than filled with background color forCPCDayCellState.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 implementationRenders background of a day cell. Default implementation calls
drawCellBackground (state:color:frame:in:)
with corresponding values ofcontext
.Default Implementation
Declaration
Swift
func drawCellBackground(in context: Context)
Parameters
context
Cell rendering context.
-
drawCellTitle(in:)
Default implementationRenders title of a day cell. Default implementation calls
drawCellTitle (title:attributes:frame:in:)
with corresponding values ofcontext
.Default Implementation
Declaration
Swift
func drawCellTitle(in context: Context)
Parameters
context
Cell rendering context.
-
Context
Extension methodSee also
CPCDayCellRenderingContext
.Declaration
Swift
public typealias Context = CPCDayCellRenderingContext
-
drawCellBackground(state:color:frame:in:)
Extension methodDefault implementation of day cell background drawing. Fills
frame
ofcontext
withcolor
ifstate
!=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.
-
drawCellTitle(title:attributes:frame:in:)
Extension methodDefault implementation of day cell title drawing. Renders
title
withattributes
inframe
ofcontext
.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.