我们开始安装RxSwift
pod 'RxSwift'
pod 'RxCocoa'
pod update --verbose --no-repo-update (时间不多的话,用这条)
然后command + B 编译一下
首先我们新建一个页面,最简单的那种文件名在下面
MoreViewController.swift
MoreViewController.storyboard
这里storyboard你可以随便布局,我这里放了一个输入框,一个按钮
接下来在别的Controller里面进行触发展示。
//这里是我定义的全局常量
fileprivate let disposeBag = DisposeBag()
//这里用到了rxswift
tipButton.rx.controlEvent(.touchUpInside)
.subscribe(onNext: { [weak self]in
//获得storyboard
let storyboard = UIStoryboard(name: String(describing: MoreViewController.self), bundle: nil)
// 初始化我们的MoreViewController控制器
let moreLoginVC = storyboard.instantiateViewController(withIdentifier: String(describing: MoreViewController.self)) as! MoreViewController
// 这里定义一个它的宽高属性
moreLoginVC.modalSize = (width: .full, height: .custom(size:Float(screenHeight )))
// 这里进行show,self代表当前的视图。
self!.present(moreLoginVC, animated: true, completion: nil)
}).disposed(by: disposeBag)
RxSwift的高级操作还有很多。这里只是作为简单使用