使用NSDictionaty来设置文本的属性:

NSDictionary * attributes = @{NSFontAttributeName: [UIFont fontWithName:@"Heiti SC" size:20]};
[confirmBarButton setTitleTextAttributes:attributes forState:UIControlStateNormal];

完整代码:

    self.inputToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
self.inputToolbar.translucent = NO;
self.inputToolbar.barTintColor= [UIColor colorWithRed:26.0/255.0 green:194.0/255.0 blue:97.0/255.0 alpha:1];
self.inputToolbar.tintColor = [UIColor whiteColor]; UIBarButtonItem *confirmBarButton = [[UIBarButtonItem alloc] initWithTitle:@"Confirm" style:UIBarButtonItemStylePlain target:self action:@selector(doneKeyboard)];
NSDictionary * attributes = @{NSFontAttributeName: [UIFont fontWithName:@"Heiti SC" size:20]};
[confirmBarButton setTitleTextAttributes:attributes forState:UIControlStateNormal]; UIBarButtonItem *spaceBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(doneKeyboard)]; self.inputToolbar.items = [NSArray arrayWithObjects: spaceBarButton, confirmBarButton, spaceBarButton, nil];
self.textView.inputAccessoryView = self.inputToolbar;

參考链接:http://stackoverflow.com/questions/2720733/how-do-you-set-the-font-size-on-a-uibarbuttonitem

iOS 改动toolbar里面文字的字体和大小的更多相关文章

  1. iOS - 富文本直接设置文字的字体大小和颜色

    富文本效果图: 富文本实现代码: UILabel *orderSureLabel = [Common lableFrame:CGRectZero title:] textColor:[UIColor ...

  2. iOS中动态计算不同颜色、字体的文字高度

    在改项目bug的时候,有一个问题动态计算label的高度,前开发者竟然用字符串长度除以14.16这样的常量来计算是否换行,结果cell的高度问题非常严重. 因为label内容里有部分关键字是要另一种颜 ...

  3. iOS开发-- 设置UIButton的文字显示位置、字体的大小、字体的颜色

    btn.frame = CGRectMake(x, y, width, height); [btn setTitle: @"search" forState: UIControlS ...

  4. 文字排版--字体(font-family)

    我们可以使用css样式为网页中的文字设置字体.字号.颜色等样式属性.下面我们来看一个例子,下面代码实现:为网页中的文字设置字体为宋体. body{font-family:"宋体"; ...

  5. 蜗牛爱课 -- iOS 设置UIButton的字体的大小、显示位置、大小

    /设置按钮上的自体的大小 //[btn setFont: [UIFont systemFontSize: 14.0]];    //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法 ...

  6. iOS开发之计算文字尺寸

    /** *  计算文字尺寸 * *  @param text    需要计算尺寸的文字 *  @param font    文字的字体 *  @param maxSize 文字的最大尺寸 */ - ( ...

  7. CSS.01 -- 选择器及相关的属性文本、文字、字体、颜色、

    与html相比,Css支持更丰富的文档外观,Css可以为任何元素的文本和背景设置颜色:允许在任何元素外围设置边框:允许改变文本的大小,装饰(如下划线),间隔,甚至可以确定是否显示文本. 什么是CSS? ...

  8. CSS3基础(2)—— 文字与字体相关样式、盒子类型、背景与边框相关样式、变形处理、动画功能

    一. CSS3 文字与字体相关样式 1. 给文字添加阴影 text-shadow: length length length ccolor; 属性适用于文本阴影,指定了水平阴影,垂直阴影,模糊的距离, ...

  9. Python3 tkinter基础 Label compound 图片上显示文字 fg字体颜色 font字体大小

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

随机推荐

  1. Ubuntu下Hadoop的安装和配置

    最近又需要要搭hadoop环境,所以开始学习,下面是我的笔记,仅供大家参考! Hadoop安装: JDK1.6+ 操作系统:Linux,Window和Unix也可以做Hadoop的开发,只有Linux ...

  2. javascript当中的this详解

    总结this的3个规则: this是调用上下文,上下文被创建或者初始化时才确定 非严格模式:this是全局对象:严格模式:this是undefined 函数调用 a. 以函数形式调用的函数通常不使用t ...

  3. csu 1556(快速幂)

    1556: Jerry's trouble Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 787  Solved: 317[Submit][Statu ...

  4. bootstrap使用前注意点和盒子模型

    bootstrap注意事项: https://getbootstrap.com/docs/4.0/getting-started/introduction/#quick-start 盒子模型: htt ...

  5. 791. Custom Sort String

    S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sort ...

  6. day2 列表中常用的方法

    列表中有很多方法,下面来看看常用的方法,我们知道,字符串是以字符列表形式存储的.因此上面学习的字符串中的很多方法在列表中也有.     1.extend() extend()列表的扩展,把两个列表进行 ...

  7. 牛客网 牛客练习赛43 C.Tachibana Kanade Loves Review-最小生成树(并查集+Kruskal)+建虚点+读入挂

    链接:https://ac.nowcoder.com/acm/contest/548/C来源:牛客网 Tachibana Kanade Loves Review 时间限制:C/C++ 2秒,其他语言4 ...

  8. Python编程举例-装饰器

    装饰器的通常用途是扩展已定义好的函数的功能 一个浅显的装饰器编程例子 #装饰器函数 def outer(fun): def wrapper(): #添加新的功能 print('验证') fun() r ...

  9. Jquery操作select标签的常用方法

    <select id="search"> <option value='1'>baidu</option> <option value=' ...

  10. Codeforces Round #436 (Div. 2) E. Fire(dp 记录路径)

    E. Fire time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...