美文网首页
iOS navigation geekband

iOS navigation geekband

作者: AAup | 来源:发表于2016-03-17 21:44 被阅读104次

    创建:
    -initWithrootviewController:
    -initWithNavigationBarClass:toolbarClass;
    -setViewControllers:animated;

     例子
     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    
    self.window.backgroundColor = [UIColor whiteColor];
    RoowViewController *root = [[RoowViewController alloc]init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:root];//先将root添加在navigation上
    self.window.rootViewController = nav;//navigation加在window上
    
    self.window.backgroundColor = [UIColor blueColor];
    [self.window makeKeyAndVisible];
    return YES; }
    
    创建
     设置属性:
    self.navigationItem.title = @"主页";//设置navigationbar上显示的标题
    [self.navigationController.navigationBar setTranslucent:NO];//设置navigationbar的半透明
    [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];//设置navigationbar的颜色
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:Nil];//设置navigationbar左边按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:Nil];//设置navigationbar右边按钮
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];//设置navigationbar上左右按钮字体颜色
    
    设置
     toolbar
    //toolbar 加载 一般为隐藏
    [self.navigationController  setToolbarHidden:NO animated:YES];
    UIBarButtonItem *one = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
    UIBarButtonItem *two = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:nil action:nil];
    UIBarButtonItem *three = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil];
    UIBarButtonItem *four = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:nil action:nil];
    UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    [self setToolbarItems:[NSArray arrayWithObjects:flexItem, one, flexItem, two, flexItem, three, flexItem, four, flexItem, nil]];
    
    toolbar

    Navigation bar


    Navigation bar

    UINavigationController


    UINavigationController

    NavController


    NavController

    引入导航器


    引入导航器

    相关文章

      网友评论

          本文标题:iOS navigation geekband

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