CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Aug 2017 |
Maintained by jeff_njut.
FJController is based on TabBarController, NavigationController and ViewController to easilly configure styles.
To integrate FJController into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'FJController', :git => 'https://github.com/jeffnjut/FJController.git'Then, run the following command:
$ pod installIf any update occurs, run the following command:
$ pod updateImport FJController Header File
#import <FJController/FJControllerHeader.h>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
... ...
FJTabItem *firstTabItem = [FJTabItem tabItem:@"First"
unselectedImage:@"first_unselected"
selectedImage:@"first_selected"
unselectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor lightGrayColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
selectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
controller:[FirstViewController class]];
FJTabItem *secondTabItem = [FJTabItem tabItem:@"Second"
unselectedImage:@"second_unselected"
selectedImage:@"second_selected"
unselectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor lightGrayColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
selectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
controller:[SecondViewController class]];
FJTabItem *thirdTabItem = [FJTabItem tabItem:@"Third"
unselectedImage:@"third_unselected"
selectedImage:@"third_selected"
unselectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor lightGrayColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
selectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
controller:[ThirdViewController class]];
FJTabItem *fourthTabItem = [FJTabItem tabItem:@"Fourth"
unselectedImage:@"fourth_unselected"
selectedImage:@"fourth_selected"
unselectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor lightGrayColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
selectedTextAttrs:@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont systemFontOfSize:10]}
controller:[FourthViewController class]];
[[FJControllerMgr sharedInstance] setTabItems:@[firstTabItem,secondTabItem,thirdTabItem,fourthTabItem]];
// 设置标签栏Bar的属性(tabbar_bg是背景图,优先级大于barTintColor)
FJTabBarConfig *tabBarConfig = [FJTabBarConfig tabBarConfig:@"tabbar_bg"
disableLine:NO
translucent:NO
barTintColor:[UIColor whiteColor]
selectedColor:nil
unselectedColor:nil];
[[FJControllerMgr sharedInstance] setTabBarConfig:tabBarConfig];
... ... // 其它设置
// 初始化FJTabViewController
FJTabViewController *tabViewController = [[FJTabViewController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[self.window setRootViewController:tabViewController];
... ...
return YES;
}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
... ...
// 设置导航栏Bar的属性
FJNavBarConfig *navBarConfig = [FJNavBarConfig navBarConfig:@"nav_back_black"
imageBackSize:CGSizeMake(24.0, 24.0)
navbarTranslucent:NO
navbarTintColor:[UIColor whiteColor]
titleColor:[UIColor blackColor]
titleFont:[UIFont systemFontOfSize:18]];
[[FJControllerMgr sharedInstance] setNavBarConfig:navBarConfig];
... ...
}- (instancetype)init
{
FJControllerItem *item = [FJControllerItem controllerItem:@"图片"];
self = [super initWithControllerItem:item];
if (self) {
}
return self;
}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
... ...
FJCommonControllerConfig *commonControllerConfig = [[FJCommonControllerConfig alloc] init];
commonControllerConfig.backgroundColor = [UIColor whiteColor];
[[FJControllerMgr sharedInstance] setCommonControllerConfig:commonControllerConfig];
[commonControllerConfig setCommonInitialBlock:^{
NSLog(@"通用Initial Block");
}];
[commonControllerConfig setCommonDeallocBlock:^{
NSLog(@"通用Dealloc Block");
}];
[commonControllerConfig setCommonMemorywarningBlock:^{
NSLog(@"通用Memory Warning Block");
}];
[commonControllerConfig setCommonViewWillAppearBlock:^{
NSLog(@"通用View Will Appear Block");
}];
[commonControllerConfig setCommonViewDidAppearBlock:^{
NSLog(@"通用View Did Appear Block");
}];
[commonControllerConfig setCommonViewWillDisappearBlock:^{
NSLog(@"通用View Will Disappear Block");
}];
[commonControllerConfig setCommonViewDidDisappearBlock:^{
NSLog(@"通用View Did Disappear Block");
}];
... ...
}
- (instancetype)init
{
CustomNavView *customNavView = [[[NSBundle mainBundle] loadNibNamed:@"CustomNavView" owner:nil options:nil] lastObject];
__weak typeof(customNavView) weakCustomNavView = customNavView;
[customNavView bk_whenTapped:^{
NSInteger badge = [weakCustomNavView.lb_badge.text integerValue];
weakCustomNavView.lb_badge.text = [NSString stringWithFormat:@"%d", (int)badge+1];
}];
FJControllerItem *item = [FJControllerItem controllerItem:nil
title:@"Detail"
navbarTintColor:[UIColor whiteColor]
disableStatusBar:NO
disableNavBar:NO
edgesForExtendedLayout:UIRectEdgeAll
leftNavBarButtonResource:@"TEXT:返回"
leftNavBarButtonSize:CGSizeZero
leftNavBarCustomView:nil
rightNavBarButtonResource:nil
rightNavBarButtonSize:CGSizeZero
rightNavBarCustomView:customNavView
rightSupplementNavBarButtonResource:@"nav_camera_black"
rightSupplementNavBarButtonSize:CGSizeZero
rightSupplementNavBarCustomView:nil
navBarTextButtonColor:nil
navBarTextButtonFont:nil];
__weak typeof(self) weakSelf = self;
// 按钮事件
[item setLeftNavBarButtonBlock:^{
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
[item setRightNavBarButtonBlock:^{
NSLog(@"自定义Text按钮");
DetailViewController *detailVC = [[DetailViewController alloc] init];
[weakSelf.navigationController pushViewController:detailVC animated:YES];
}];
[item setRightSupplementNavBarButtonBlock:^{
NSLog(@"自定义图片按钮");
}];
// 系统事件
[item setInitialBlock:^{
NSLog(@"DetailVC的Initial Block");
}];
[item setDeallocBlock:^{
NSLog(@"DetailVC的Dealloc Block");
}];
[item setMemorywarningBlock:^{
NSLog(@"DetailVC的Memory Warning Block");
}];
[item setViewWillAppearBlock:^{
NSLog(@"DetailVC的View Will Appear Block");
}];
[item setViewDidAppearBlock:^{
NSLog(@"DetailVC的View Did Appear Block");
}];
[item setViewWillDisappearBlock:^{
NSLog(@"DetailVC的View Will Disappear Block");
}];
[item setViewDidDisappearBlock:^{
NSLog(@"DetailVC的View Did Disappear Block");
}];
self = [super initWithControllerItem:item];
if (self) {
}
return self;
}
// Splash View
DemoStayView *demoStayView = [[[NSBundle mainBundle] loadNibNamed:@"DemoStayView" owner:nil options:nil] lastObject];
[[FJControllerMgr sharedInstance] setStayView:demoStayView];
Image Should be Rendered As Origin Mode
Feel free to open an issue or pull request, if you need help or there is a bug.
FJController is available under the MIT license. See the LICENSE file for more info.
The MIT License (MIT)
Copyright (c) 2017 Jeff
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.