This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-iOS/Example/Example/DemoVC.m
2019-12-21 20:14:23 +08:00

39 lines
1.1 KiB
Objective-C

//
// Created by pengfei.zhou on 2019/11/19.
// Copyright (c) 2019 pengfei.zhou. All rights reserved.
//
#import "DemoVC.h"
#import "Doric.h"
@interface DemoVC ()
@property(nonatomic, copy) NSString *filePath;
@end
@implementation DemoVC
- (instancetype)initWithPath:(NSString *)filePath {
if (self = [self init]) {
_filePath = filePath;
}
return self;
}
- (void)viewDidLoad {
self.title = self.filePath;
self.view.backgroundColor = [UIColor whiteColor];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *demoPath = [path stringByAppendingPathComponent:@"demo"];
NSString *fullPath = [demoPath stringByAppendingPathComponent:self.filePath];
NSString *jsContent = [NSString stringWithContentsOfFile:fullPath encoding:NSUTF8StringEncoding error:nil];
DoricPanel *panel = [DoricPanel new];
[panel.view also:^(UIView *it) {
it.width = self.view.width;
it.height = self.view.height - 88;
it.top = 88;
[self.view addSubview:it];
}];
[self addChildViewController:panel];
[panel config:jsContent alias:self.filePath];
}
@end