oc项目中手动导入chart(swift文件)

来源:互联网 发布:淘宝安全中心官网 编辑:程序博客网 时间:2024/05/06 06:26

最近OC项目中有用到第三方swift插件图表,charts,在手动导入过程中遇到一些问题,记录一下,便于以后方便查找

1:新建工程

2:github下载charts文件

3:然后将解压后的文件夹整个拖到自己的工程文件夹下(很多教程只让拖xcodeproj文件,但我拖了不好使),如下图:


4:然后将刚才拖进去的Charts-master文件下的Charts.xcodeproj   add Files to 项目中,如下图


5:添加charts框架,如下图


6:创建与swift的桥接文件,会生成两个文件,如下图


7:在ChartsDemo(你的工程文件名)-Bridging-Header.h文件中添加#import <Charts/Charts.h>

8:然后在需要使用的地方导入这俩头文件就好:

#import "ChartsDemo-Bridging-Header.h"  

#import "ChartsDemo-swift.h"

#import "ViewController.h"#import "ImportChart-Bridging-Header.h"#import "importChart-swift.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    //例如:因为没有赋值,所以会出现没有数据的折线图    LineChartView *lView = [[LineChartView alloc]initWithFrame:CGRectMake(20, 100, 80, 70)];    lView.backgroundColor = [UIColor cyanColor];    [self.view addSubview:lView];}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end



0 0
原创粉丝点击