1.OC中自定义方法
- (UIViewController *)addOneChildVcClass:(Class)vcClass title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
UIViewController *vc = [[vcClass alloc] init];
...
}
swift中自定义方法
func addChildVCByClassString(childControllerClass: AnyClass,title:String ,image:String, selectedImage:String) {
guard let vc = childControllerClass as? UIViewController.Type else{
return
}
addChildVC(vc.init(), title:title, image: image, selectedImage: selectedImage)
}
2.OC中传入的参数为
[self addOneChildVcClass:[HWHomeViewController class] title:@"首页" image:@"tabbar_home" selectedImage:@"tabbar_home_selected"];
addChildVCByClass(HomeViewController.classForCoder(), title: "首页", image: "tabbar_home", selectedImage: "tabbar_home_selected")