许可证 1.1.0

Licensy 1.1.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期最后发布2018年6月
SPM支持SPM

Guille Garcia Rebolo维护。



Licensy 1.1.0

  • David Jimenez Guinaldo 和 Guillermo Garcia Rebolo

Licensy for iOS

Build Status CocoaPods compatible License: MIT Swift Version Platform

Licensy for iOS

版权所有 © David Jimenez Guinaldo & Guillermo Garcia Rebolo。

Licensy 是一个iOS自包含类,允许您显示一个列表,列出您在应用程序中使用的所有第三方库,并预览有关其许可证和版权的一些数据。

要求

Licensy 工作在iOS 9+上,并需要ARC构建。它依赖于以下Apple框架,这些框架应该已经包含在大多数Xcode模板中:

  • Foundation.framework
  • UIKit.framework

您需要最新的开发者工具才能构建 Licensy。旧的Xcode版本可能也可以工作,但兼容性将不会进行显式维护。

安装

使用 CocoaPods 是将 Licensy 添加到项目的推荐方法。

pod 'Licensy'
  1. 运行 pod install 以安装pod。
  2. 在需要的地方使用 Licensy,如果您的项目是Objective-C,则使用 @import Licensy;如果项目是Swift,则使用 import Licensy

使用

此库的基本使用方法涉及创建一个具有类 LicensyTableUITableView,该类为我们提供Pod,并添加应用程序中包含的库。

库结构

库是包含使用库及其许可证所有信息的对象

属性 描述 示例
name 库的名称 "Licensy"
organization 创建库的组织的名称 "RetoLabs"
url 可以找到库的网址 "https://github.com/guille969/Licensy"
copyright 库的版权信息 "版权 (c) 2017 RetoLabs"
license 库使用的许可证 MITLicense()

如上所述,license 是类型的属性 License,有一些更常用的,而 Licensy 提供的

名称 JSON标识符
Apache软件许可证2.0 "ASL20"
BSD 3条款许可证 "BSD3"
创意共享署名-禁止演绎3.0未修改版本 "CCAND"
GNU通用公共许可证2.0 "GPL20"
GNU通用公共许可证3.0 "GPL30"
GNU Lesser通用公共许可证2.1 "LGPL"
ISC许可 "ISC"
MIT许可证 "MIT"
Mozilla公共许可证,版本2.0 "MPL20"

您还可以使用对象类 CustomLicense 创建自定义许可证,以构建上述未列出的许可证。

从对象添加库

您可以创建库对象并将它们提供给 'Licensy' 表单以列出它们。您可以在本存储库的示例中查看详细示例。

//Load tableView with an array on Library
let librariesArray: Array<LibraryEntity> = [
    LibraryEntity(name: "Library 1", organization: "RetoLabs", url: "[email protected]", copyright: "Guillermo Garcia Rebolo", license: MITLicense()),
    LibraryEntity(name: "Library 2", organization: "RetoLabs", url: "[email protected]", copyright: "David Jiménez Guinaldo", license: ApacheSoftwareLicense20()),
    LibraryEntity(name: "Library 3", organization: "RetoLabs", url: "[email protected]", copyright: "Guillermo Garcia Rebolo", license: GnuGeneralPublicLicense30()),
    LibraryEntity(name: "Library 4", organization: "RetoLabs", url: "[email protected]", copyright: "David Jiménez Guinaldo", license: GnuGeneralPublicLicense30())
]
tableView.setLibraries(librariesArray)

从JSON添加库

您可以将所有库及其许可证列在一个包含在您的应用程序包中的JSON文件中,格式如下

{
    "libraries": [
        {
            "name": "Licensy",
            "organization": "RetoLabs",
            "url": "https://github.com/guille969/Licensy",
            "copyright": "Copyright (C) 2017 RetoLabs",
            "license": "MIT"
        },
        {
            "name": "MGBottomSheet",
            "organization": "Guillermo Garcia Rebolo",
            "url": "https://github.com/guille969/MGBottomSheet",
            "copyright": "Copyright (C) 2017 Guillermo Garcia Rebolo",
            "license": "MIT"
        }
    ]
}

要使用,您可以在您的视图控制器中调用以下代码

//libraries is the name of the JSON file in your project with your 3rd Party libraries
let path = Bundle.main.path(forResource: "libraries", ofType: "json")!
self.tableView.setLibraries(forJsonResourcePath: path)

或这种方式,只需提供JSON资源的名称即可

tableView.setLibraries(forJsonResourceName: "librerias")

自定义外观

您可以自定义一些样式属性

属性 描述 示例
headerContentColor 用于头部标题、下划线头部及其附件的 UIColor UIColor.white
headerBackgroundColor 用于头部背景的 UIColor UIColor(red:0.15, green:0.30, blue:0.38, alpha:1.0)
accentColor 用于图书馆链接和许可按钮的 UIColor UIColor(red:0.00, green:0.50, blue:0.50, alpha:1.0)
roundLicenseButton 一个布尔属性,用于决定是否对许可按钮进行圆角处理 true
accesory 一个枚举属性,用于在两种不同的附件样式之间选择(.arrow 或 .plus) .arrow
licenseSize 一个枚举属性,用于在两种不同的许可格式之间选择(.minimal 或 .extended) .minimal

自定义示例

tableView.appearance.accentColor = UIColor.red
tableView.appearance.roundLicenseButton = true
tableView.appearance.accesory = .plus
tableView.appearance.licenseSize = .extended

我们提供了 3 种不同的预定义样式

Licensy for iOS Licensy for iOS Licensy for iOS
默认样式 iOS 样式 橙色样式

应用预定义样式

tableView.appearance.setIOSDefaultAppearance() //iOS style
tableView.appearance.setOrangeFitAppearance() //Orange fit