Latest 1.0.1
Homepage https://github.com/yscode001/YSModal
License MIT
Platforms ios 9.0
Dependencies YSBase
Frameworks UIKit
Authors

模态弹框(向上、下、左、右,半屏有遮罩),常用于操作类弹框

YSModal

环境

swift4.2、iOS9.0

使用步骤

1、导入框架

pod 'YSModal'

2、导入命名空间

import YSModal

使用小技巧

PresentedViewController 使用说明和示例

1、PresentedViewController只需要继承YSModal_presentedVC即可;

2、默认向上弹框,高度为屏高一半,遮罩颜色为黑色,透明度0.5;

3、如果需要自定义方向、长度,遮罩颜色,透明度,重写以下相应的方法即可;

4、如果是UINavigationController,继承YSModal_presentedNavC,用法一样;

import UIKit

class PresentedVC: YSModal_presentedVC {

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.orange
    }

    // 重写此方法,设置遮罩颜色和透明度
    override func ys_setupMaskView() -> (bgC: UIColor, alpha: CGFloat) {
        return (UIColor.black, 0.5)
    }

    // 重写此方法,设置弹框方向和长度
    override func ys_setupDirectionAndLength() -> (direction: YSModal_direction, length: CGFloat) {
        return (.toRight, 200)
    }

    @IBAction func dismissAction(_ sender: UIButton) {
        dismiss(animated: true, completion: nil)
    }
}

PresentingViewController 使用说明及示例

1、在需要Modal展现的地方,直接present即可,注意,presentedVC一定是YSModal_presentedVC子类对象

import UIKit

class ViewController: UIViewController{

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func modalAction(_ sender: UIButton) {
        let sb = UIStoryboard(name: "Main", bundle: nil)
        let presentedVC = sb.instantiateViewController(withIdentifier: "p") as! YSModal_presentedVC

        // Modal展现
        present(presentedVC, animated: true, completion: nil)
    }
}

Latest podspec

{
    "name": "YSModal",
    "version": "1.0.1",
    "summary": "u6a21u6001u5f39u6846uff0cu65b9u5411u4e0eu957fu5ea6u81eau5b9au4e49uff0cu6709u906eu7f69u534au900fu660eu6548u679c",
    "homepage": "https://github.com/yscode001/YSModal",
    "license": "MIT",
    "authors": {
        "ys": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/yscode001/YSModal.git",
        "tag": "1.0.1"
    },
    "source_files": "YSModal/YSModal/YSModal/*.swift",
    "frameworks": "UIKit",
    "dependencies": {
        "YSBase": []
    }
}

Pin It on Pinterest

Share This