ios+html5+工具栏,IOS开发 导航栏和工具栏

本凶学习内容:

1.导航栏和工具栏的概念

2.导航瘭和工具栏的属性

barStyle:导航栏风格

barTintColor:导航栏颜色

tintColor:导航栏风格颜色

toolbarItems:工具栏元素数组

UIBarItemFlexibleSpace:自动调整距离按钮

3.导航栏和工具栏的使用

创建一个根视图命名为VCRoot

【VCRoot.m】

#import "VCRoot.h"

#import"VCSecond.h"

@interface VCRoot()

@end

@implementation VCRoot

-(void)viewDidLoad{

[super viewDidLoad];

self.view.backgroundColor=[UIColor yellowColor];

//设置导航栏风格颜色,UIBarStyleBlack:黑色风格,UIBarStyleDefault默认风格

self.navigationController.navigationBar.barStyle=UIBarStyleDefault:

//将风格设置为不透明

self.navigationController.navigationBar.translucent=NO;

//设置导航栏颜色

self.navigationController.navgationBar.barTintColor=[UIColor redColor];

//设置导航 元素项目按扭的风格颜色

self.navigationController.navigationBar.tintColor=[UIColor blackColor];]

//隐藏导航栏,两个使用任何一个都可以,默认值都是NO

//self.navigationController.navigationBar.hidden=YES;

self.navigationController.navigationBarHidden=YES;

self.title=@"根视图";

UIBarButton* btn=[[UIBarButtonItem alloc]initWithTitle:@“右侧按扭”style:UIBarButtonItemStylePlan target:nil aciton:nil];

self.navigationItem.rightBarButtonItem=btn;

//实现工具栏对象,默认工具栏时隐藏的

self.navigationController.toolbarHidden=no;

//设置工具栏透明度

self.navigationController.toolbar.translucents=NO;

UIBarButtonItem* btn01=[[UIBarButtonItem alloc]initWithTitle:@"left"style:UIBarButtonItemStylePlan target:nil action:nil];

UIBarButtonItem* btn02=[[UIBarButtonItem alloc]initWithBarButtonSytemItem:UIBarButtonSystemItemCamera traget:self action:@selction(pressNext)];

UIButton* btnImage=[UIButton buttonWithType:UIButtonTypeCuston];

[btnImage setImage:[UIImage imageNamed:@"btn02,jpg"]forSate:UIControlStateNormal];

btnImage.frame=CGRectMake(0,0,60;60);

//因定宽度占位按钮

UIBarButtonItem* btnF01=[[UIBarButton alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

btnF01.width=90;

//创建自动计算宽度按钮

UIBarButtonItem* btnF02=[[UIBarttonItem alloc]initWithBarButtonSystemItem]:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

UIBarButtonItem* btn03=[UIBarButtonItem alloc]initWithCustonView:btnImage];

//按钮数组创建

NSArray( arrayBtns=[NSArray arrayWithObjects:btn01,btnF02,btn02,btnF02,btn03,nil];

self.toolbarItems=arrayBtns;

}

-(void)pressNext{

VCSecond* vc=[[VCSecond alloc]init];

[self.navigationController pushViiewController:vc animated:YES];

}

创建一个子视图命名VCSecend

【AppDelegate.m】

#import"AppDelegate.h"

#import"VCroot.h"

@interface AppDelegate()

@end

@implementation AppDelegate

-(BOOL)application:(UIApplication *)application didFinishLaunchingWighOptions:(NSDictionary *)launchOptions{

self.window=[[UIWindow alloc]initWithFrame:[UIScreen aminScreen].bounds];

UINavigationController* nav=[[UINavigationController alloc]initVithRootViewController:[[VCRoot alloc]init]];

self.window.rootViewController=nav;

[self.window makeKeyAndVisible];

return YES;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值