iOS 模态 弹出

2019-01-02  本文已影响0人  已经多年不写Unity

查询了很多资料,模态窗体的弹出

出bug了没时间解释了

//
//  ViewController.swift
//  MyTest01
//
//  Created by Wirhui on 2019/1/2.
//  Copyright © 2019 Wirhui. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
    }

    @IBAction func mytest(_ sender: Any) {
        print("hello")
        var secVC = SecondViewController()
        secVC.view.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.1)
        //设置新页面为覆盖层
        secVC.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
        //设置被覆盖层
        self.modalPresentationStyle = UIModalPresentationStyle.currentContext
        //以模态方式进行加载
        self.present(secVC, animated: true, completion: nil)
    }
    
}


上一篇 下一篇

猜你喜欢

热点阅读