测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布时间最新发布 | 2017年2月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Matthew Rigdon 维护。
该框架允许您轻松设置 View Controller 以显示受 Apple 新闻应用启发的新闻文章。只需设置所需的字段并运行,您将为文章获得一个好的视图。
要运行示例项目,克隆 repo,并首先从 Example 目录运行 pod install
。
MRArticleViewController 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
pod 'MRArticleViewController'
导入模块
import MRArticleViewController
继承 ArticleViewController
class ViewController: ArticleViewController
在 viewDidLoad
中,设置以下 必需 属性 在 super.viewDidLoad()
之前
override func viewDidLoad() {
// required
imageView.image = UIImage(named: "pulpfiction")!
headline = "LA gangsters witness supposed \"Divine Intervention\""
author = "Quentin Tarantino"
date = NSDate()
body = bodyText
super.viewDidLoad()
}
可选:在 viewDidLoad
中,设置以下 可选 属性 在 super.viewDidLoad()
之前
...
// Uses the algorithm from UIImageColors to extract the colors from the image and color the
// background, headline, author, date, and body accordingly. Defaults to false, but highly
// recommended to set to true. More on this feature below.
autoColored = true
// If you don't like the autoColor feature, you can also color each component individually
backgroundColor = UIColor.black
headlineColor = UIColor.yellow
authorColor = UIColor.orange
dateColor = UIColor.gray
bodyColor = UIColor.gray
super.viewDidLoad()
完成!
autoColored
的更多信息此库利用了 UIImageColors 的算法。设置 autoColor = true
从 image
中提取颜色并将背景颜色应用于背景
待办事项
[ ] 添加新样式
MRArticleViewController遵循MIT许可。有关更多信息,请参阅LICENSE文件。请同时参考Panic的原始授权以了解autoColor功能。