iProgressHUD 开源项目使用教程
1. 项目的目录结构及介绍
iProgressHUD 项目的目录结构如下:
iProgressHUD/
├── iProgressHUD
│ ├── iProgressHUD.swift
│ ├── iProgressHUD.xcodeproj
│ ├── iProgressHUD.xcworkspace
│ ├── iProgressHUDTests
│ └── iProgressHUDUITests
├── iProgressHUDDemo
│ ├── iProgressHUDDemo
│ ├── iProgressHUDDemo.xcodeproj
│ ├── iProgressHUDDemo.xcworkspace
│ ├── iProgressHUDDemoTests
│ └── iProgressHUDDemoUITests
├── .gitignore
├── .swift-version
├── .travis.yml
├── LICENSE
├── Preview.png
├── README.md
├── iProgressHUD.podspec
└── iProgressHUDLogo.png
目录介绍
- iProgressHUD: 包含 iProgressHUD 库的核心文件和测试文件。
- iProgressHUDDemo: 包含 iProgressHUD 的演示应用和测试文件。
- .gitignore: Git 忽略文件配置。
- .swift-version: Swift 版本声明。
- .travis.yml: Travis CI 配置文件。
- LICENSE: 项目许可证(MIT 许可证)。
- Preview.png: 项目预览图。
- README.md: 项目说明文档。
- iProgressHUD.podspec: CocoaPods 配置文件。
- iProgressHUDLogo.png: 项目 Logo。
2. 项目的启动文件介绍
iProgressHUD 项目的启动文件位于 iProgressHUDDemo/iProgressHUDDemo/ViewController.swift
。
ViewController.swift
import UIKit
import iProgressHUD
class ViewController: UIViewController, iProgressHUDDelegete {
override func viewDidAppear(_ animated: Bool) {
let iprogress: iProgressHUD = iProgressHUD()
iprogress.delegete = self
iprogress.attachProgress(toViews: view)
view.showProgress()
}
func onShow(view: UIView) {
print("onShow")
}
func onDismiss(view: UIView) {
print("onStop")
}
func onTouch(view: UIView) {
print("onTouch")
}
}
文件介绍
- ViewController.swift: 演示应用的主视图控制器,包含 iProgressHUD 的初始化和使用示例。
3. 项目的配置文件介绍
iProgressHUD 项目的配置文件主要包括 .travis.yml
和 iProgressHUD.podspec
。
.travis.yml
language: objective-c
osx_image: xcode11.3
script:
- xcodebuild test -project iProgressHUD/iProgressHUD.xcodeproj -scheme iProgressHUD -destination 'platform=iOS Simulator,name=iPhone 8,OS=latest'
文件介绍
- .travis.yml: Travis CI 配置文件,用于自动化测试和构建。
iProgressHUD.podspec
Pod::Spec.new do |spec|
spec.name = "iProgressHUD"
spec.version = "1.0.0"
spec.summary = "An elegant, lightweight and responsive progress HUD for iOS app."
spec.description = <<-DESC
iProgressHUD is a progress HUD for iOS app. It is easy to use and supports 32 indicators by NVActivityIndicatorView.
DESC
spec.homepage = "https://github.com/icaksama/iProgressHUD"
spec.license = { :type => "MIT", :file => "LICENSE" }
spec.author = { "icaksama" => "icaksama@gmail.com" }
spec.platform = :ios, "9.0"
spec.source = { :git => "https://github.com/icaksama/iProgressHUD.git", :tag => "#{spec.version}" }
spec.source_files = "iProgress