Ios 如何将File.swift导入ViewController.h和viceversa?
我试图创建一个file.swift文件,以从中的导航栏更改颜色,但当我试图在ViewController中导入file.swift文件时,它显示了一个错误 -------代码--------Ios 如何将File.swift导入ViewController.h和viceversa?,ios,objective-c,swift,import,Ios,Objective C,Swift,Import,我试图创建一个file.swift文件,以从中的导航栏更改颜色,但当我试图在ViewController中导入file.swift文件时,它显示了一个错误 -------代码-------- 错误表示:预期;在appName bridgeing Header.h中进行顶级声明后,您需要导入所需的.h文件,这些文件将以swift代码提供 在Objective-C文件中,您需要导入生成的标题module_name-Swift.h,其中包含所有Swift类。这样,swift课程将在目标c中提供。以下是
错误表示:预期;在
appName bridgeing Header.h
中进行顶级声明后,您需要导入所需的.h文件,这些文件将以swift代码提供
在Objective-C文件中,您需要导入生成的标题
module_name-Swift.h
,其中包含所有Swift类。这样,swift课程将在目标c中提供。以下是苹果公司的官方文件:
在Objective-C中使用Swift
您需要依靠Xcode生成的头文件向Objective-C公开这些文件。此自动生成的文件是Objective-C头文件,用于声明目标中的Swift接口
构建设置
中,您可以找到您的产品模块名称
导入“-Swift.h”
-bridge Header.h
(另外,您可以在纯Objective-C
项目中创建Swift
,XCode将提示您是否需要桥接文件)那个文件包含什么?这是一节课吗?
//Esta clase se creo para dar color a la NavViewController por medio de su valor en RGB
import UIKit
class NavViewController: UINavigationController {
override func viewDidLoad() {
//Se divide el valor RGB entre 255.0
UINavigationBar.appearance().barTintColor = UIColor(red: 110/255.0, green: 192/255.0, blue: 238/255.0, alpha: 1.0)
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/