要运行示例项目,请克隆仓库,然后首先从示例目录中运行pod install
。
Objective-C
// Load Licenses1 from a plist
NSString *path = [[NSBundle mainBundle] pathForResource: @"Licenses1" ofType:@"plist"];
NSArray * licenses = [[NSArray alloc] initWithContentsOfFile:path];
NSArray * ddLicenses = [DDLicense licenseArrayFromDictionaryArray: licenses];
DDLicensesViewController * vc = [[DDLicensesViewController alloc] init];
vc.title = @"Licenses";
vc.licenses = ddLicenses;
// Optional: license list font
vc.licenseListFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:17];
// Optional: license font
vc.licenseFont = [UIFont fontWithName:@"Courier" size:17];
// Add close button to navigation bar
vc.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:@selector(closeButtonAction:)];
// Put DDLicensesViewController in a UINavigationController and show
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentViewController:nvc animated:YES completion:nil];
Swift
// Load Licenses1 from a plist
let path: NSString = NSBundle.mainBundle().pathForResource("Licenses", ofType: "plist")!;
let licenses = NSArray(contentsOfFile: path);
let ddLicenses: NSArray = DDLicense.licenseArrayFromDictionaryArray(licenses);
var vc: DDLicensesViewController = DDLicensesViewController()
vc.title = "Licenses";
vc.licenses = ddLicenses;
// Optional: license list font
vc.licenseListFont = UIFont(name: "HelveticaNeue-Light", size: 17);
// Optional: license font
vc.licenseFont = UIFont(name: "Courier", size: 17);
self.navigationController?.pushViewController(vc, animated: true);
Doug Diego
DDLicenseViewController受MIT许可协议保护。有关更多信息,请参阅LICENSE文件。