将flutter项目添加到现有iOS应用-framework

2023-08-07  本文已影响0人  xieyinghao

将原项目转换成module的形式

进入项目使用命令行打包

flutter build ios-framework --output=../flutter_app

打出包后,分为debug、profile、release三种形式

image.png image.png

#import "ViewController.h"
#import <Flutter/Flutter.h>
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 40)];
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:UIColor.orangeColor forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}
-(void)clickAction {
    FlutterViewController * flutter = [[FlutterViewController alloc]init];
    flutter.view.backgroundColor = [UIColor yellowColor];
    [self presentViewController:flutter animated:YES completion:^{
        
    }];
}

@end

参考:https://www.jianshu.com/p/73dc67912555

上一篇 下一篇

猜你喜欢

热点阅读