美文网首页
将flutter项目添加到现有iOS应用-framework

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

作者: xieyinghao | 来源:发表于2023-08-07 21:45 被阅读0次

将原项目转换成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

相关文章

网友评论

      本文标题:将flutter项目添加到现有iOS应用-framework

      本文链接:https://www.haomeiwen.com/subject/psagpdtx.html