Swift 项目的星级评分组件
CocoaPods 是 Cocoa 项目的依赖管理工具。您可以使用以下命令安装它:
$ gem install cocoapods
要使用 CocoaPods 将 MLStarRating 集成到您的 Xcode 项目中,请在您的 Podfile
中指定它:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
pod 'MLStarRating', '~> 1.0.3'
然后,运行以下命令:
$ pod install
Carthage 是一个去中心化的依赖管理工具,可以自动将框架添加到您的 Cocoa 应用程序。
您可以使用 Homebrew 使用以下命令安装 Carthage:
$ brew update
$ brew install carthage
要使用 Carthage 将 MLStarRating 集成到您的 Xcode 项目中,请在您的 Cartfile
中指定它:
github "micheltlutz/MLStarRating" ~> 1.0.3
要将 MLStarRating 用作 Swift Package Manager 包,只需在您的 Package.swift 文件中添加以下内容:
// swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "HelloMLStarRating",
dependencies: [
.package(url: "https://github.com/micheltlutz/MLStarRating.git", .upToNextMajor(from: "1.0.3"))
],
targets: [
.target(name: "HelloMLStarRating", dependencies: ["MLStarRating"])
]
)
如果您不想使用上述任何依赖管理工具,您可以手动将 MLStarRating 集成到您的项目中。
cd
进入您的顶级项目目录,然后运行以下命令(如果您的项目未初始化为 git 仓库):$ git init
$ git submodule add https://github.com/micheltlutz/MLStarRating.git
$ git submodule update --init --recursive
MLStarRating
文件夹,然后将 MLStarRating.xcodeproj
拖到应用程序的 Xcode 项目的 Project Navigator 中。它应该嵌套在您应用程序的蓝色项目图标下。它位于所有其他 Xcode 组的上方还是下方无关紧要。
MLStarRating.xcodeproj
,并验证部署目标与您的应用程序目标匹配。+
按钮。MLStarRating.xcodeproj
文件夹,每个文件夹都有两个不同版本的 MLStarRating.framework
嵌套在 Products
文件夹中。选择哪个
Products
文件夹无关紧要。
选择 MLStarRating.framework
。
就是这样!
MLStarRating.framework
会自动添加为目标依赖项、链接框架和嵌入式框架,并在复制文件构建阶段完成,这是在模拟器和设备上构建所需的一切。
+
按钮。MLStarRating.framework
。import MLStarRating
let mlStarRating = MLStarRating()
mlStarRating.didChangeStar = { starCount in
print("Star selected: \(starCount)")
}
let mlStarRating = MLStarRating()
mlStarRating.emptyStarImageName = "string name image"
mlStarRating.fullStarImageName = "string name image"
mlStarRating.setupStars() // to change configuration buttons
let mlStarRating = MLStarRating()
mlStarRating.selectedStar = 4
欢迎提交 Issues 和 Pull Requests!
查看 文档
MLLineChart 文档 (80% 已文档化)
Michel Anderson Lutz Teixeira @michel_lutz
MLStarRating 在 MIT 许可下发布。 有关详细信息,请参阅 LICENSE。