swift导入OC版QMUI SDK

@高效码农  October 24, 2019

一、xcode11 新建swift5 项目

参考:https://www.xugj520.cn/archives/xcode-swift.html

二、接入 SDK

在项目目录下执行

$ pod init

在 Podfile 中指定:

pod 'QMUIKit'

在项目目录终端下执行:

$ pod install

三、新建桥接的头文件

2019-10-24T03:39:22.png

并添加到
2019-10-24T03:40:45.png

四、在头文件中导入

#import <QMUIKit/QMUIKit.h>

五、在swift文件中使用QMUI

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "aaa"
        self.view.backgroundColor = UIColor(hue: 0.50, saturation: 0.20, brightness: 0.86, alpha: 1.00)
        
        let button = QMUIButton();
        button.frame = CGRect(x: 10, y: 210, width: 300, height: 50)
        button.backgroundColor = UIColor.red
        button.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
        self.view.addSubview(button)
    }
    
    @objc func buttonClick(){
        print("被点击了")
    }


}


评论已关闭