UIToolBar - 官方文档
继承关系:UIToolBar -> UIView -> UIResponder -> NSObject。
toolBar是一个工具栏,用于显示一个或多个按钮。其按钮叫做toolBar items,是UIBarButtonItem对象。
@property(nonatomic, copy) NSArray *items //在toolBar上显示的items。其中的每个item都是UIBarButtonItem对象。按照其在数组中的位置依次显示。该属性的任何变化不会产生动画效果。默认为nil值。
@property(nonatomic) UIBarStyle barStyle // 确定toolBar的外观。默认值为UIBarStyleDefault,其为白色的背景和黑色的内容。
@property(nonatomic, retain) UIColor *barTintColor // 指定toolBar的背景颜色。
@property(nonatomic, retain) UIColor *tintColor // 指定item的颜色。
@property(nonatomic, assign, getter=isTranslucent) BOOL translucent // 指明toolBar是否是透明的,默认为YES。
@property(nonatomic, assign) id<UIToolbarDelegate> delegate //委托对象应该遵守UIToolBarDelegate协议。
- (void)setBackgroundImage:(UIImage *)backgroundImage forToolbarPosition:(UIBarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics
// 设置图片作为toolBar的背景。
- (void)setItems:(NSArray *)items animated:(BOOL)animated // 如果animated为YES,则当toolBar的items改变时,附带一些动画效果。
- (void)setShadowImage:(UIImage *)shadowImage forToolbarPosition:(UIBarPosition)topOrBottom //如果想要使用自定义的shadow image,必须用setBackgroundImage:forToolbarPosition:barMetrics:方法设置自定义的背景图片。如果使用了默认的背景图片,不管shadowImage为什么,都使用默认的值。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
CGRect bound = [[UIScreen mainScreen] bounds];
self.window = [[UIWindow alloc] initWithFrame:bound];
self.window.rootViewController = [[UIViewController alloc] init];
CGRect toolBarRect = CGRectMake(, bound.size.height / , bound.size.width, );
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:toolBarRect];
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"item1"
style:UIBarButtonItemStyleDone
target:self
action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"item2"
style:UIBarButtonItemStyleDone
target:self
action:nil];
// UIImage *image1 = [UIImage imageNamed:@"beauty0.jpg"];
// UIImage *image2 = [UIImage imageNamed:@"beauty3.jpg"];
// [toolBar setBackgroundImage:image1 forToolbarPosition:UIBarPositionBottom barMetrics:UIBarMetricsDefault];
// [toolBar setShadowImage:image2 forToolbarPosition:UIBarPositionBottom];
// toolBar.items = @[item1, item2];
[toolBar setItems:@[item1, item2] animated:YES];
toolBar.barTintColor = [UIColor redColor];
toolBar.tintColor = [UIColor whiteColor];
[self.window addSubview:toolBar];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
运行结果为:

UIToolBar - 官方文档的更多相关文章
- 【AutoMapper官方文档】DTO与Domin Model相互转换(上)
写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...
- 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合
这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...
- 2DToolkit官方文档中文版打地鼠教程(二):设置摄像机
这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...
- 2DToolkit官方文档中文版打地鼠教程(一):初始设置
这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...
- 【AutoMapper官方文档】DTO与Domin Model相互转换(中)
写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...
- 【AutoMapper官方文档】DTO与Domin Model相互转换(下)
写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...
- Ionic2系列——Ionic 2 Guide 官方文档中文版
最近一直没更新博客,业余时间都在翻译Ionic2的文档.之前本来是想写一个入门,后来觉得干脆把官方文档翻译一下算了,因为官方文档就是最好的入门教程.后来越翻译越觉得这个事情确实比较费精力,不知道什么时 ...
- Kotlin开发语言文档(官方文档)-- 目录
开始阅读Kotlin官方文档.先上文档目录.有些内容还未阅读,有些目录标目翻译还需琢磨琢磨.后续再将具体内容的链接逐步加上. 文档链接:https://kotlinlang.org/docs/kotl ...
- 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍
我们在前一篇文章微软新神器-Power BI,一个简单易用,还用得起的BI产品中,我们初步介绍了Power BI的基本知识.由于Power BI是去年开始微软新发布的一个产品,虽然已经可以企业级应用, ...
随机推荐
- Android 针对单个Activity设置状态栏颜色
代码如下: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//因为不是所有的系统都可以设置颜色的,在4.4以下就不可以. ...
- 【Spring源码解读】bean标签中的属性
说明 今天在阅读Spring源码的时候,发现在加载xml中的bean时,解析了很多标签,其中有常用的如:scope.autowire.lazy-init.init-method.destroy-met ...
- Pycharm基本设置和插件安装
Pycharm调节主题和字体 调节主题:File - Setting - Editor - Color Scheme - 选择个人喜欢的风格 调节字体大小,感觉默认字体有点小,对我这样的老人家,至少要 ...
- 【转】c# [Serializable]的作用
http://blog.csdn.net/chinarenkai/article/details/3220452 如果你做远程方法调用(RPC)时,比如,服务器端有个类A及对象a,客户端需要无视网络的 ...
- selenium的基本用法
selenium需要配合一个driver 我使用的是chrome的driver 注意一定要下载对应浏览器版本的driver 否则会报错的 http://chromedriver.storage.go ...
- JHipster生成微服务架构的应用栈(五)- 容器编排示例
本系列文章演示如何用JHipster生成一个微服务架构风格的应用栈. 环境需求:安装好JHipster开发环境的CentOS 7.4(参考这里) 应用栈名称:appstack 认证微服务: uaa 业 ...
- 前后端分离djangorestframework——路由组件
在文章前后端分离djangorestframework——视图组件 中,见识了DRF的视图组件强大,其实里面那个url也是可以自动生成的,就是这么屌 DefaultRouter urls文件作如下调整 ...
- C语言 矩阵的转置及矩阵的乘法
C语言 矩阵的转置及矩阵的乘法 //凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 1.矩阵的转置 #include<stdio.h> #defi ...
- 力扣算法题—069x的平方根
实现 int sqrt(int x) 函数. 计算并返回 x 的平方根,其中 x 是非负整数. 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去. 示例 1: 输入: 4 输出: 2 示例 ...
- CISCO 动态路由(OSPF)
OSPF(开放式最短路径优先):是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由.是对链路 ...