044设置屏幕中显示不同字体的文本

效果如下:

ViewController.h

1 #import <UIKit/UIKit.h>
2
3 @interface ViewController : UITableViewController
4 @property (strong, nonatomic) NSMutableDictionary *mDicFontName;
5 @property (strong, nonatomic) NSArray *arrFamilyName;
6
7 @end

ViewController.m

 1 #import "ViewController.h"
 2
 3 @interface ViewController ()
 4 @end
 5
 6 @implementation ViewController
 7
 8 - (void)viewDidLoad {
 9     [super viewDidLoad];
10 }
11
12 - (void)didReceiveMemoryWarning {
13     [super didReceiveMemoryWarning];
14     // Dispose of any resources that can be recreated.
15 }
16
17 - (id)init {
18     if (self = [super initWithStyle:UITableViewStyleGrouped]) {
19         self.title = @"Menu";
20         if (!_mDicFontName) {
21             _mDicFontName = [[NSMutableDictionary alloc] initWithCapacity:32];
22             _arrFamilyName = [[UIFont familyNames] sortedArrayUsingSelector:@selector(compare:)];
23
24             for (id familyName in _arrFamilyName) {
25                 NSArray *arrFont = [UIFont fontNamesForFamilyName:familyName];
26                 NSLog(@"%@", [arrFont description]);
27                 [_mDicFontName setObject:arrFont forKey:familyName];
28             }
29         }
30     }
31     return self;
32 }
33
34 #pragma mark - UITableView methods
35 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
36     return [_arrFamilyName count];
37 }
38
39 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
40     NSString *familyName = [_arrFamilyName objectAtIndex:section];
41     return [[_mDicFontName objectForKey:familyName] count];
42 }
43
44 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
45     static NSString *cellIdentifier = @"cell";
46     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
47     if (!cell) {
48         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
49     }
50
51     NSString *familyName = [_arrFamilyName objectAtIndex:indexPath.section];
52     NSString *fontName = [[_mDicFontName objectForKey:familyName] objectAtIndex:indexPath.row];
53     cell.textLabel.text = fontName;
54     cell.textLabel.font = [UIFont fontWithName:fontName size:[UIFont labelFontSize]];
55     return cell;
56 }
57
58 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
59     return [_arrFamilyName objectAtIndex:section];
60 }
61
62 @end
时间: 2024-12-08 06:46:35

044设置屏幕中显示不同字体的文本的相关文章

141设置屏幕中文本的横向对齐方式(扩展知识:设置标签行间距)

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @end ViewController.m 1 #import "ViewController.h" 2 #import "KMLabel.h" 3 4 @interface ViewController () 5 - (void)layoutUI; 6 @

设置secureCRT中vim的字体颜色

1.在/etc/vimrc新增以下一行 syntax on 注:上述方法对root用户无效,原因为在一般用户中,alias vi=vim,而在root用户中默认无此设置,因此若需要root用户也显示颜色,可以(1)用vim命令编辑文件(2)在~/.bashrc中添加alias vi=vim. 2.设置secureCRT属性. 设置secureCRT中vim的字体颜色

Oracle EBS的BIP报表中显示特殊字体

http://oracleseeker.com/2009/08/25/font_mapping_setup_for_special_character_print_in_oracle_ebs_bip/ 如若在BIP报表中使用了一些特殊的字体,这些字体在JRE的字体库中没有的话,则BIP报表的运行结果就不正确,最典型的例子就是条码字体的打印. 如下图是我在rtf模板中使用code39字体设计的条码显示 但是在Oracle EBS环境下运行之后的结果如下,条码字体的格式丢失了: 这是由于FO引擎在生

eclipse 对齐行号在括号中显示和字体调整

笔者 : 本笃庆军 一.括号对齐:指和C/C++里面一样.上下括号对齐~~~ 第一步:Project->preferences->Java->Code Style->Formatter 第二步:点击右边的New在profile name 里面随便填写一个名字.点击ok 选择标签页Braces 把全部的Same line 统统(除了最后一个Array initializer)改成Next line 保存就可以 二.显示行号: 直接右击编辑框你想显示行号的位置.勾选"显示行号

034在屏幕中显示一个工具条

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @end ViewController.m 1 #import "ViewController.h" 2 3 @interface ViewController () 4 - (void)nextDidPush; 5 @end 6 7 @implementation ViewC

如何设置css3中placeholder的字体颜色

input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #666; } input:-moz-placeholder, textarea:-moz-placeholder { color:#666; } input::-moz-placeholder, textarea::-moz-placeholder { color:#666; } input:-ms-input-placeholder, 

059在屏幕中显示一个文本输入框

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @property (strong, nonatomic) UITextField *txtFMessage; 5 6 @end ViewController.m 1 #import "ViewController.h" 2 3 @interface ViewControlle

汇编一点点提高3——键盘输入8位二进制数,存入NUM单元,并在屏幕上显示对应的16进制数

此程序要注意一下几点: 1.dos1号功能--带回显的键盘输入,自动存入al 2.dos7号功能--不带回显的键盘输入,自动存入al,若要在屏幕中显示要调用DOS2号功能 3.将输入的多个二进制数转换为ASCII码 input:  mov ah,1  int 21h  add bl,bl  cmp al,'1'  jnz P1  inc bl  P1: dec ch  jnz input 4.换行子程序: newline: mov ah,2 mov dl,13 int 21h mov ah,2

应用键横竖屏切换;label中显示图片;不同类型设备适配的代码;UIWebView字体大小、字体颜色、背景色的设置;

最近总结的工作中遇到的小问题在这里共享 ,希望对大家能有帮助 1.横屏的一个应用在修改个人资料过程从相册取图片或者拍照的过程中,横纵屏切换引起再次进入程序时应用变纵屏的bug --------------主页面控制器中点击进入个人资料页面的地方:---------------------- - (void)changepersonIcon{ UIActionSheet*actionSheet = [[UIActionSheetalloc] initWithTitle:@"选择封面图片"