继承关系: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 - 官方文档的更多相关文章

  1. 【AutoMapper官方文档】DTO与Domin Model相互转换(上)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  2. 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  3. 2DToolkit官方文档中文版打地鼠教程(二):设置摄像机

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  4. 2DToolkit官方文档中文版打地鼠教程(一):初始设置

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  5. 【AutoMapper官方文档】DTO与Domin Model相互转换(中)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  6. 【AutoMapper官方文档】DTO与Domin Model相互转换(下)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  7. Ionic2系列——Ionic 2 Guide 官方文档中文版

    最近一直没更新博客,业余时间都在翻译Ionic2的文档.之前本来是想写一个入门,后来觉得干脆把官方文档翻译一下算了,因为官方文档就是最好的入门教程.后来越翻译越觉得这个事情确实比较费精力,不知道什么时 ...

  8. Kotlin开发语言文档(官方文档)-- 目录

    开始阅读Kotlin官方文档.先上文档目录.有些内容还未阅读,有些目录标目翻译还需琢磨琢磨.后续再将具体内容的链接逐步加上. 文档链接:https://kotlinlang.org/docs/kotl ...

  9. 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍

    我们在前一篇文章微软新神器-Power BI,一个简单易用,还用得起的BI产品中,我们初步介绍了Power BI的基本知识.由于Power BI是去年开始微软新发布的一个产品,虽然已经可以企业级应用, ...

随机推荐

  1. python语言学习--1

    第一天 item: 当字符串中出现 反斜杠'\' 时,输出时会把它当做转义字符处理,所以结果中不会出现它,若要正常输出则需要在字符串前面加上r, 我想r的意思是religion即“原始”的意思: it ...

  2. SpringBoot-学习笔记

    启动方式 运行main方法 @SpringBootApplication public class BootApplication { public static void main(String[] ...

  3. CentOS 安装开发环境 并安装coTurn

    从官网 https://www.centos.org/download/ 下载镜像文件 从163的镜像站点下载,速度较快 http://mirrors.163.com/centos/7/isos/x8 ...

  4. Linux 最小化安装后IP的配置(手动获取静态IP地址)

    一.图形化界面配置(假设为电脑A) 如果你的Linux安装有图形化界面,那么通过以下方式来配置: 我这里是有两块网卡,第一个网卡在上篇中已经通过DHCP来配置了:Linux 最小化安装后IP的配置(D ...

  5. Symantec Backup Exec Agent 推送错误Error connecting to the remote computer. Ensure that the computer is available, has WMI enabled and is not blocked by a firewall

    如果在Symantec Backup Server上推送Symantec Backup Exec Agent到数据库服务器遇到“"Error connecting to the remote ...

  6. [20181109]12cR2 的pre_page_sga参数

    [20181109]12cR2 的pre_page_sga参数.txt --//12CR2改变了参数pre_page_sga设置为True.设置为true有好处也有缺点.--//先看看官方的定义:ht ...

  7. shell编程-文件包含(十)

    shell文件包含指的是脚本中包含外部脚本,然后将其封装起来重新作为一个独立的文件而存在 文件包含格式 使用"."+空格+文件名:. filename 或者source+空格+文件 ...

  8. vue分页组件二次封装---每页请求特定数据

    关键步骤: 1.传两个参数:pageCount (每页条数).pageIndex (页码数): 2.bind方法的调用 <!-- 这部分是分页 --> <div class=&quo ...

  9. 在ubuntu18.04上安装EOS

    在ubuntu18.04上安装EOS 在ubuntu18.04上安装EOS的目的: 把交易所的eos转到eos主网,防止交易所跑路或者交易所被黑客攻击 在不联网的安全环境下,用eos官方的命令行工具, ...

  10. 使用Jenkins遇到的问题

    前言 本文记录我在使用jenkins过程中遇到的一些问题. 无法执行bat 如果出现bat执行出错,解决办法如下: 1. 打开 服务,找到 jenkins的服务 2. 修改jenkins的属性如下:( ...