CNTimelineCell is a helpful framework to generate a timeline with UITableView.
Sample screenshot:
Requirements
iOS 11+
Swift 5.3+
Installation
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding CNTimelineCell as a dependency is as easy as adding it to the dependencies value of your Package.swift.
CNTimelineCell
Sample screenshot:
Requirements
Installation
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the
swiftcompiler.Once you have your Swift package set up, adding CNTimelineCell as a dependency is as easy as adding it to the
dependenciesvalue of yourPackage.swift.How to use
- Import CNTimelineCell
Import
CNTimelineCellwhen you need.Prepare your
[CNTimelineCellItem], for examples:Register TableViewCell as below:
Render your cell:
With the configuration above, you will have the result like this:
Configuration
CNTimelineCellItem
var title: Stringmessage titlevar content: String?message contentvar image: UIImage?image iconvar leftType: TimelineTypeleft TimelineType (default:.none)var rightType: TimelineTyperight TimelineType (default:.none)Sample CNTimelineCellItem:
Update style and item in cellForRowAtIndexPath
Output:
Styling
LineType
There are five line types in TimelineType:
start,end,spot,lineandnoneLineStyle
Line style can be configured by LineStyle struct.
var lineWidth: CGFloatwidth of the central line (default:6.0)var spotDiameter: CGFloatdiameter of circle spot (default:20.0)var spotColor: UIColorcolor of central circle spot (default.white)var lineColor: UIColorcolor of line (defaultRGB(0, 144, 182))var spotOffsetY: CGFloatvertical offset of spot (default:29.0)BubbleStyle
Set the dialog style using BubbleStyle object
var arrowOffsetY: CGFloatvertical offset of arrow (default:30.0)var borderWidth: CGFloatwidth of border (default:2.0)var borderColor: UIColorcolor of border (default:RBC(0, 147, 51))public var backgroundColor: UIColorbutton background color (default.clear)CNTimelineCellStyle
Pass the LineStyle and BubbleStyle to CNTimelineCellStyle object to configure CNTimelineCell
var leftLineStyle: LineStyleleft Timeline style (default:LineStyle())var rightLineStyle: LineStyleright Timeline style (default:LineStyle())var bubbleStyle: BubbleStylebubble message style (default:BubbleStyle())var messageSeparator: UIColorcolor of separator line in message (default:.lightGray)Author
Chris Ng (chrisnyw@gmail.com)
License
CNTimelineCell is available under the MIT license. See the LICENSE file for more info.