mirror of https://github.com/xaoxuu/ProHUD
example
This commit is contained in:
parent
b6f4fdd781
commit
7a0eaac1ae
|
@ -9,6 +9,7 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import ProHUD
|
import ProHUD
|
||||||
import Inspire
|
import Inspire
|
||||||
|
import WebKit
|
||||||
|
|
||||||
class TestGuardVC: BaseListVC {
|
class TestGuardVC: BaseListVC {
|
||||||
|
|
||||||
|
@ -16,8 +17,8 @@ class TestGuardVC: BaseListVC {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
vm.addSection(title: "简单使用") { (sec) in
|
vm.addSection(title: "简单使用") { (sec) in
|
||||||
// MARK: 场景:删除菜单
|
// MARK: 删除菜单
|
||||||
sec.addRow(title: "场景:删除菜单") {
|
sec.addRow(title: "示例:删除菜单") {
|
||||||
Guard.push("del") { (vc) in
|
Guard.push("del") { (vc) in
|
||||||
vc.update { (vm) in
|
vc.update { (vm) in
|
||||||
vm.add(action: .destructive, title: "删除") { [weak vc] in
|
vm.add(action: .destructive, title: "删除") { [weak vc] in
|
||||||
|
@ -36,8 +37,8 @@ class TestGuardVC: BaseListVC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: 场景:升级至专业版
|
// MARK: 升级至专业版
|
||||||
sec.addRow(title: "场景:升级至专业版") {
|
sec.addRow(title: "示例:升级至专业版") {
|
||||||
// 可以通过id来避免重复
|
// 可以通过id来避免重复
|
||||||
Guard.push("pro") { (vc) in
|
Guard.push("pro") { (vc) in
|
||||||
vc.identifier = "pro"
|
vc.identifier = "pro"
|
||||||
|
@ -84,10 +85,9 @@ class TestGuardVC: BaseListVC {
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.addSection(title: "添加自定义视图") { (sec) in
|
vm.addSection(title: "添加自定义视图") { (sec) in
|
||||||
// MARK: 场景:选项切换
|
// MARK: 选项切换
|
||||||
sec.addRow(title: "场景:选项切换", subtitle: "很方便地添加自定义控件") {
|
sec.addRow(title: "示例:修改背景蒙版", subtitle: "很方便地添加自定义控件") {
|
||||||
Guard.push() { (vc) in
|
Guard.push() { (vc) in
|
||||||
|
|
||||||
if #available(iOS 13.0, *) {
|
if #available(iOS 13.0, *) {
|
||||||
let imgv = UIImageView(image: UIImage(systemName: "photo.fill.on.rectangle.fill"))
|
let imgv = UIImageView(image: UIImage(systemName: "photo.fill.on.rectangle.fill"))
|
||||||
vc.textStack.addArrangedSubview(imgv)
|
vc.textStack.addArrangedSubview(imgv)
|
||||||
|
@ -99,15 +99,20 @@ class TestGuardVC: BaseListVC {
|
||||||
// Fallback on earlier versions
|
// Fallback on earlier versions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加标题
|
||||||
vc.vm.add(title: "背景蒙版")
|
vc.vm.add(title: "背景蒙版")
|
||||||
|
// 添加标题
|
||||||
vc.vm.add(subTitle: "选择一种模糊效果")
|
vc.vm.add(subTitle: "选择一种模糊效果")
|
||||||
|
// 添加控件
|
||||||
let seg = UISegmentedControl(items: ["extraLight", "light", "dark", "none"])
|
let seg = UISegmentedControl(items: ["extraLight", "light", "dark", "none"])
|
||||||
seg.selectedSegmentIndex = 1
|
seg.selectedSegmentIndex = 1
|
||||||
vc.textStack.addArrangedSubview(seg)
|
vc.textStack.addArrangedSubview(seg)
|
||||||
seg.snp.makeConstraints { (mk) in
|
seg.snp.makeConstraints { (mk) in
|
||||||
mk.height.equalTo(40)
|
mk.height.equalTo(40)
|
||||||
}
|
}
|
||||||
|
// 添加标题
|
||||||
vc.vm.add(subTitle: "设置蒙版透明度")
|
vc.vm.add(subTitle: "设置蒙版透明度")
|
||||||
|
// 添加控件
|
||||||
let slider = UISlider()
|
let slider = UISlider()
|
||||||
slider.minimumValue = 0
|
slider.minimumValue = 0
|
||||||
slider.maximumValue = 100
|
slider.maximumValue = 100
|
||||||
|
@ -116,31 +121,39 @@ class TestGuardVC: BaseListVC {
|
||||||
slider.snp.makeConstraints { (mk) in
|
slider.snp.makeConstraints { (mk) in
|
||||||
mk.height.equalTo(40)
|
mk.height.equalTo(40)
|
||||||
}
|
}
|
||||||
|
// 添加按钮
|
||||||
vc.vm.add(action: .default, title: "OK") { [weak vc] in
|
vc.vm.add(action: .default, title: "OK") { [weak vc] in
|
||||||
vc?.pop()
|
vc?.pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: 场景:隐私协议页面
|
// MARK: 隐私协议页面
|
||||||
sec.addRow(title: "场景:隐私协议页面", subtitle: "也可以完全控制整个页面") {
|
sec.addRow(title: "示例:弹出隐私协议页面", subtitle: "也可以完全控制整个页面") {
|
||||||
Guard.push("license") { (vc) in
|
Guard.push("license") { (vc) in
|
||||||
|
// 全屏
|
||||||
vc.isFullScreen = true
|
vc.isFullScreen = true
|
||||||
vc.update { (vm) in
|
// 添加标题
|
||||||
let titleLabel = vm.add(title: "隐私协议")
|
vc.vm.add(title: "隐私协议").snp.makeConstraints { (mk) in
|
||||||
titleLabel.snp.makeConstraints { (mk) in
|
|
||||||
mk.height.equalTo(44)
|
mk.height.equalTo(44)
|
||||||
}
|
}
|
||||||
let tv = UITextView()
|
// 添加网页
|
||||||
tv.backgroundColor = .white
|
let web = WKWebView.init(frame: .zero)
|
||||||
tv.isEditable = false
|
web.layer.masksToBounds = true
|
||||||
vc.textStack.addArrangedSubview(tv)
|
web.layer.cornerRadius = ProHUD.shared.config.guard.buttonCornerRadius
|
||||||
tv.text = "这里可以插入一个webView"
|
web.scrollView.showsHorizontalScrollIndicator = false
|
||||||
vm.add(message: "请认真阅读以上内容,当您阅读完毕并同意协议内容时点击接受按钮。")
|
if let url = URL(string: "https://xaoxuu.com/wiki/prohud/") {
|
||||||
|
web.load(URLRequest(url: url))
|
||||||
vm.add(action: .default, title: "接受") { [weak vc] in
|
|
||||||
vc?.pop()
|
|
||||||
}
|
}
|
||||||
|
vc.textStack.addArrangedSubview(web)
|
||||||
|
web.snp.makeConstraints { (mk) in
|
||||||
|
mk.leading.trailing.equalToSuperview()
|
||||||
|
}
|
||||||
|
// 添加文本
|
||||||
|
vc.vm.add(message: "请认真阅读以上内容,当您阅读完毕并同意协议内容时点击接受按钮。")
|
||||||
|
// 添加按钮
|
||||||
|
vc.vm.add(action: .default, title: "接受") { [weak vc] in
|
||||||
|
vc?.pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import ProHUD
|
import ProHUD
|
||||||
import SnapKit
|
import SnapKit
|
||||||
|
import WebKit
|
||||||
|
|
||||||
class ViewController: BaseListVC {
|
class ViewController: BaseListVC {
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ class ViewController: BaseListVC {
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
title = "\(Bundle.main.infoDictionary?["CFBundleName"] ?? "ProHUD")"
|
title = "\(Bundle.main.infoDictionary?["CFBundleName"] ?? "ProHUD")"
|
||||||
|
|
||||||
|
|
||||||
vm.addSection(title: "测试项目") { (sec) in
|
vm.addSection(title: "测试项目") { (sec) in
|
||||||
sec.addRow(title: "Toast", subtitle: "横幅控件,支持图片、标题和正文。\n不支持添加按钮,但可以接受一个点击事件。") {
|
sec.addRow(title: "Toast", subtitle: "横幅控件,支持图片、标题和正文。\n不支持添加按钮,但可以接受一个点击事件。") {
|
||||||
let vc = TestToastVC()
|
let vc = TestToastVC()
|
||||||
|
@ -54,6 +56,35 @@ class ViewController: BaseListVC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm.addSection(title: "更多") { (sec) in
|
||||||
|
sec.addRow(title: "查看在线文档", subtitle: "https://xaoxuu.com/wiki/prohud/") {
|
||||||
|
Guard.push("license") { (vc) in
|
||||||
|
// 全屏
|
||||||
|
vc.isFullScreen = true
|
||||||
|
// 添加标题
|
||||||
|
vc.vm.add(title: "ProHUD").snp.makeConstraints { (mk) in
|
||||||
|
mk.height.equalTo(44)
|
||||||
|
}
|
||||||
|
// 添加网页
|
||||||
|
let web = WKWebView.init(frame: .zero)
|
||||||
|
web.layer.masksToBounds = true
|
||||||
|
web.layer.cornerRadius = ProHUD.shared.config.guard.buttonCornerRadius
|
||||||
|
web.scrollView.showsHorizontalScrollIndicator = false
|
||||||
|
if let url = URL(string: "https://xaoxuu.com/wiki/prohud/") {
|
||||||
|
web.load(URLRequest(url: url))
|
||||||
|
}
|
||||||
|
vc.textStack.addArrangedSubview(web)
|
||||||
|
web.snp.makeConstraints { (mk) in
|
||||||
|
mk.leading.trailing.equalToSuperview()
|
||||||
|
}
|
||||||
|
// 添加按钮
|
||||||
|
vc.vm.add(action: .default, title: "关闭") { [weak vc] in
|
||||||
|
vc?.pop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue