TimelineTableViewCell
TimelineTableViewCell 是由 UITableViewCell 实现的简单时间线视图。TimelineTableViewCell 的 UI 设计灵感来源于 ISTimeline。
要求
- iOS 9.0 或更高版本
v1.0.1-
- Swift 3
v1.2-
- Swift 4
v1.3
- Swift 5
v2.0+
- v1.3版本及以下版本的重大变更:thumbnailImageView被UIStackView替换,以支持多个缩略图。
- 不再支持iOS9.0及以下版本。
安装
Swift包管理器
Swift包管理器(Swift Package Manager)是一个用于自动分发Swift代码的工具,与swift
编译器集成。
一次atory you have your Swift package set up, adding TimelineTableViewCell as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/kf99916/TimelineTableViewCell.git")
]
CocoaPods
CocoaPods 是Cocoa项目的依赖管理器。有关使用和安装说明,请访问其网站。要将TimelineTableViewCell集成到您的Xcode项目中使用CocoaPods,请在您的 Podfile
中指定它。
pod 'TimelineTableViewCell'
用法
导入
import TimelineTableViewCell
集成
注册Nib
let bundle = Bundle(for: TimelineTableViewCell.self)
let nibUrl = bundle.url(forResource: "TimelineTableViewCell", withExtension: "bundle")
let timelineTableViewCellNib = UINib(nibName: "TimelineTableViewCell",
bundle: Bundle(url: nibUrl!)!)
tableView.register(timelineTableViewCellNib, forCellReuseIdentifier: "TimelineTableViewCell")
出队
let cell = tableView.dequeueReusableCell(withIdentifier: "TimelineTableViewCell",
for: indexPath) as! TimelineTableViewCell
// Configure TimelineTableViewCell...
时间轴点
行中的点由TimelinePoint对象表示。
var diameter: CGFloat
行中点的直径(默认 6.0
)
var lineWidth: CGFloat
点的厚度(默认 2.0
)
var color: UIColor
行中每个点的颜色(默认 UIColor.black
)
var isFilled: Bool
填充行中的点(默认 false
)
初始化器
TimelinePoint(diameter: CGFloat, lineWidth: CGFloat, color: UIColor, filled: Bool)
TimelinePoint(diameter: CGFloat, color: UIColor, filled: Bool)
TimelinePoint(color: UIColor, filled: Bool)
TimelinePoint()
时间轴
单元格中的线由Timeline对象表示,并以点作为基准分为前台线和后台线。
var width: CGFloat
线的厚度(默认 2.0
)
var frontColor: UIColor
前台线的颜色(默认 UIColor.black
)
var backColor: UIColor
后台线的颜色(默认 UIColor.black
)
var leftMargin: CGFloat
行的左外边距(默认值为 60.0
)
初始化方法
Timeline(width: CGFloat, frontColor: UIColor, backColor: UIColor)
Timeline(frontColor: UIColor, backColor: UIColor)
Timeline()
TimelineTableViewCell
单元格由 TimelineTableViewCell 对象表示。
titleLabel: UILabel!
气泡中的标题
descriptionLabel: UILabel!
描述
lineInfoLabel: UILabel!
行信息
thumbnailImageView: UIImageView!
缩略图 illustrationImageView: UIImageView!
插图
var bubbleRadius: CGFloat
气泡角落的半径(默认 2.0
)
var bubbleColor: UIColor
每个气泡的颜色(默认 .init(red: 0.75, green: 0.75, blue: 0.75, alpha: 1.0)
) viewsInStackView: [UIView]
堆叠视图中的视图。 var bubbleEnabled: Bool
启用绘制气泡(默认 true
)
使用 TimelineTableViewCell 的应用
如果您在您的应用中使用 TimelineTableViewCell 并想在此列出,请简单地创建一个 pull request。
我总是很好奇谁在使用我的项目 :)
Hikingbook - by Zheng-Xiang Ke
演示
TimelineTableViewCellDemo 是一个简单的演示应用,展示了在 storyboard 中使用 TimelineTableViewCell 的用法。
作者
Zheng-Xiang Ke, [email protected]
授权
TimelineTableViewCell 基于 MIT 许可协议。详细内容请查看 LICENSE 文件。