测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | Apache 2 |
发布最后发布 | 2017年9月 |
由 Dan Loewenherz 维护。
依赖 | |
LHSTableViewCells | >= 0 |
LHSCategoryCollection | >= 0 |
此视图控制器可以使您的应用用户快速方便地浏览其 iOS 设备上可用的字体列表。
CocoaPods 是推荐的安装方法。只需将此行添加到 Podfile 中。
pod 'LHSFontSelectionViewController', :git => 'https://github.com/lionheart/LHSFontSelectionViewController.git'
将 LHSFontSelectionViewController 集成到项目中相当简单。您只需实例化控制器,分配一个代理,然后在代理中定义所需的系统。
以下是一个快速示例
LHSFontSelectionViewController *fontSelectionViewController = [[LHSFontSelectionViewController alloc] init];
fontSelectionViewController.delegate = self;
[self.navigationController pushViewController:fontSelectionViewController];
您的代理必须遵守 LHSFontSelecting 协议,该协议定义了以下方法
fontNameForFontSelectionViewController:
setFontName:forFontSelectionViewController:
fontSizeForFontSelectionViewController:
上面的实现让您在如何实现 LHSFontSelectionViewController 方面更具灵活性。以下是在生产应用中使用它们的示例
#pragma mark - LHSFontSelecting
- (NSString *)fontNameForFontSelectionViewController:(LHSFontSelectionViewController *)viewController {
return [[NSUserDefaults standardUserDefaults] stringForKey:SettingsFontNameKey];
}
- (void)setFontName:(NSString *)fontName forFontSelectionViewController:(LHSFontSelectionViewController *)viewController {
[[NSUserDefaults standardUserDefaults] setObject:fontName forKey:SettingsFontNameKey];
}
- (CGFloat)fontSizeForFontSelectionViewController:(LHSFontSelectionViewController *)viewController {
return [Theme fontSize] + 4;
}