测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最后发布 | 2017年4月 |
由 Luca Mozzarelli 维护。
依赖项 | |
ColorArt | >= 0 |
TLYShyNavBar | >= 0 |
IDMPhotoBrowser | >= 0 |
此框架允许您轻松创建类似 Apple News 的 UIViewControllers。
它深受 MRArticleViewController 的启发,实际上其核心是对它的简单翻译。然而,我添加了一些我认为可能有用的功能。
布局如上图所示,这里还有一些额外的功能。
NSAttributedString
。LMArticleViewController 通过 CocoaPods 提供。只需将以下行添加到您的 Podfile 中。
pod 'LMArticleViewController'
您可以选择子类化 LMArticleViewController
并在 viewDidLoad:
方法中设置内容,或者创建一个 LMArticleViewController 对象,设置其属性并显示它。
- (void)viewDidLoad {
// Set custom fonts
// Size doesn't matter here, the super class overrides with default values
[self setHeadlineFont:[UIFont fontWithName:@"Nexa Bold" size:1]];
[self setAuthorFont:[UIFont fontWithName:@"Roboto-Regular" size:1]];
[self setDateFont:[UIFont fontWithName:@"Roboto-Regular" size:1]];
// Set contents
self.headline = self.dataDictionary[k_TITLE];
self.image = self.dataDictionary[k_IMAGE];
self.author = self.dataDictionary[k_AUTHOR];
self.attributedBody = self.dataDictionary[k_BODY];
self.date = self.dataDictionary[k_DATE];
// IMPORTANT! Setup must happen before [super viewDidLoad]!!
[super viewDidLoad];
}
- (void)openArticleWithContents:(NSDictionary *)dataDictionary {
LMArticleViewController* articleViewController = [[LMArticleViewController alloc]init];
[articleViewController setBodyFont:[UIFont fontWithName:@"Roboto-Medium" size:1]];
articleViewController.headline = dataDictionary[k_TITLE];
articleViewController.image = dataDictionary[k_IMAGE];
articleViewController.author = dataDictionary[k_AUTHOR];
articleViewController.attributedBody = dataDictionary[k_BODY];
articleViewController.date = dataDictionary[k_DATE];
[self.navigationController pushViewController:articleViewController animated:YES];
}