继承关系: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. Visualization of Detail Point Set by Local Algebraic Sphere Fitting

    Refers to Dynamic Sampling and Rendering of Algebraic Point Set Surfaces Growing Least Squares for t ...

  2. c++函数集锦

    1.标准C++库字符串类std::string的用法 begin       得到指向字符串开头的Iterator end       得到指向字符串结尾的Iterator rbegin        ...

  3. 使用 float 存储小数?

    很多程序员就会使用 float 类型来存储小数.sql 的 float 类型和其他大多数编程语言的 float 类型一样, 根据IEEE 754 标准使用二进制格式编码实数数据. 但是很多程序员并不清 ...

  4. Apache httpd.conf配置文件主要内容解释

    1 ServerRoot 配置 ["ServerRoot" 主要用于指定Apache的安装路径,此选项参数值在安装Apache时系统会自动把Apache的路径写入.Windows安 ...

  5. 网站流量统计PV&UV

    统计网站pv和uv PV是网站分析的一个术语,用以衡量网站用户访问的网页的数量. 对于广告主,PV值可预期它可以带来多少广告收入.一般来说,PV与来访者的数量成正比,但是PV并不直接决定页面的真实来访 ...

  6. MySQL中lock tables和unlock tables浅析

    MySQL中lock tables和unlock tables浅析   在MySQL中提供了锁定表(lock tables)和解锁表(unlock tables)的语法功能,ORACLE与SQL Se ...

  7. c/c++叉树的创建与遍历(非递归遍历左右中,不破坏树结构)

    二叉树的创建与遍历(非递归遍历左右中,不破坏树结构) 创建 二叉树的递归3种遍历方式: 1,先中心,再左树,再右树 2,先左树,再中心,再右树 3,先左树,再右树,再中心 二叉树的非递归4种遍历方式: ...

  8. 安装window 7系统----计算机经验

    上期我们已经成功制作了U盘启动并且也成功进入了PE系统了,在PE微型系统中,除了简单的装系统来恢复C盘,还有什么功能你们可以使用的呢?如果这一期我没有把其他内容讲解的话,千万别乱搞,到时我可能会讲解几 ...

  9. LeetCode算法题-Find the Difference(Java实现-五种解法)

    这是悦乐书的第214次更新,第227篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第82题(顺位题号是389).给定两个字符串s和t,它们只包含小写字母.字符串t由随机混 ...

  10. Apache Spark技术实战之6 --Standalone部署模式下的临时文件清理

    问题导读 1.在Standalone部署模式下,Spark运行过程中会创建哪些临时性目录及文件? 2.在Standalone部署模式下分为几种模式? 3.在client模式和cluster模式下有什么 ...