第5课源代码

 1 //
 2 //  ViewController.m
 3 //  Attributor
 4 //
 5 //  Created by qiuda bin on 15/11/26.
 6 //  Copyright © 2015年 qiuda bin. All rights reserved.
 7 //
 8
 9 #import "ViewController.h"
10
11 @interface ViewController ()
12
13 @property (weak, nonatomic) IBOutlet UITextView *body;
14 @property (weak, nonatomic) IBOutlet UILabel *headline;
15 @property (weak, nonatomic) IBOutlet UIButton *outlineButton;
16
17 @end
18
19 @implementation ViewController
20
21 - (void)viewDidLoad {
22     [super viewDidLoad];
23     // Do any additional setup after loading the view, typically from a nib.
24     NSMutableAttributedString *title =
25     [[NSMutableAttributedString alloc] initWithString:self.outlineButton.currentTitle];
26
27     [title setAttributes:@{NSStrokeWidthAttributeName: @3,
28                            NSStrokeColorAttributeName: self.outlineButton.tintColor}
29                    range:NSMakeRange(0, [title length])];
30     [self.outlineButton setAttributedTitle:title forState:UIControlStateNormal];
31 }
32
33 - (void)viewWillAppear:(BOOL)animated
34 {
35     [super viewWillDisappear:animated];
36     [self usePerferredFonts];
37     [[NSNotificationCenter defaultCenter] addObserver:self
38                                              selector:@selector(perferredFontsChanged:)
39                                                  name:UIContentSizeCategoryDidChangeNotification
40                                                object:nil];
41 }
42
43 - (void)perferredFontsChanged:(NSNotification *)notification
44 {
45     [self usePerferredFonts];
46 }
47
48 - (void) usePerferredFonts
49 {
50     self.body.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
51     self.headline.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
52 }
53
54 - (void)viewWillDisappear:(BOOL)animated
55 {
56     [super viewWillDisappear:animated];
57     [[NSNotificationCenter defaultCenter] removeObserver:self
58                                                     name:UIContentSizeCategoryDidChangeNotification
59                                                   object:nil];
60
61 }
62
63 - (IBAction)changeBodySelectedColorMatchButtonBackgroundColor:(UIButton *)sender {
64     [self.body.textStorage addAttribute:NSForegroundColorAttributeName
65                                   value:sender.backgroundColor
66                                   range:self.body.selectedRange];
67 }
68
69 - (IBAction)outlineBodySelection {
70     [self.body.textStorage addAttributes:@{NSStrokeWidthAttributeName:@-3,
71                                            NSStrokeColorAttributeName:[UIColor blackColor]}
72                                    range:self.body.selectedRange];
73 }
74
75 - (IBAction)unoutlineBodySelection {
76     [self.body.textStorage removeAttribute:NSStrokeWidthAttributeName
77                                      range:self.body.selectedRange];
78 }
79
80
81 - (void)didReceiveMemoryWarning {
82     [super didReceiveMemoryWarning];
83     // Dispose of any resources that can be recreated.
84 }
85
86 @end
87
88  
时间: 2024-08-26 11:48:15

第5课源代码的相关文章

第一、二课源代码

1 // 2 // Card.h 3 // Machismo 4 // 5 // Created by qiuda bin on 15/11/18. 6 // Copyright © 2015年 qiuda bin. All rights reserved. 7 // 8 9 #import <Foundation/Foundation.h> 10 11 @interface Card : NSObject 12 13 @property (strong, nonatomic) NSStrin

sqli-less5

mysql基本函数 floor,count,rand,group_concat,concat floor是取底函数,经常对小数使用,例如5.4或者5.7取底就是5,只取整数的部分,不管后面小数点的大小. rand()函数用来产生0到1之间的随机数(不包括1) concat,group_concat()函数有相似的功能,用于连接结果 测试select count(*),concat(0x3a,database(),0x3a,floor(rand()*2))name from information

PyOpenGL利用文泉驿正黑字体显示中文字体

摘要:在NeHe的OpenGL教程第43课源代码基础上,调用文泉驿正黑字体实现中文字体的显示 在OpenGL中显示汉字一直是个麻烦的事情,很多中文书籍的文抄公乐此不疲地介绍各种方法及其在windows下的代码实现.此处不在赘述,有兴趣的可以参考下面的文章: OpenGL点阵字体绘制终极解决方案!哈! 下面的代码是在NeHe教程第43课的基础上,添加了中文字体显示功能,原则上只要字体库支持,任何unicode字符串都是可以显示的 btw,unbutu下字体库文件位置:/usr/share/font

Spring框架的演变

什么是Spring 如果想要解释Spring,那么最难的部分就是对其进行分类.通常情况下,Spring被描述为构建Java应用程序的轻量级框架,但这种描述带来了两个有趣的观点. 首先,与许多其他框架(比如仅限于Web应用程序的Apache Struts)不同,可以使用Spring构建Java中的任何应用程序(例如,独立的应用程序.Web应用程序或JEE应用程序). 其次,该描述中轻量级的,因为只需要对应用程序代码进行很少的更改(如果有的话)就可以获得Spring Core所带来的好处.如果想要在

Redis2.6源代码走读第007课:压缩列表02

身体被掏空了一星期, 前天终于挣扎着继续做这个代码走读 不得不说, 压缩列表的实现复杂程度还是超出了我的预计 破天荒的第一次, 我必须手动上注释, 才能防止自己迷失在代码里面. 今天还没有录制视频, 最近一直在做公司的事, 时间也比较紧, 所以今天只是把我经过注释的压缩列表部分的代码贴出来, 同时给出一个阅读建议 在学习压缩列表的过程中, 我也参考了黄健宏先生对Redis2.6源代码的注释, 发现了黄先生注释中的一个错误. 如下: unsigned char *ziplistFind(unsig

Redis2.6源代码走读第004课:字典的实现02

这一课从代码层面上讲了字典的具体实现 并讲解了字典的创建, 结点的插入, 以及字典扩容再散列的实现 视频下载地址

Redis2.6源代码走读第007课:压缩列表01

压缩列表本身并不复杂, 但是它的实现很繁琐 这几天身体与灵魂均被掏空, 可能需要停更几天. 这一讲只讲了压缩列表本身是什么, 以及它的原理, 没有讲具体实现. 视频下载地址

Redis2.6源代码走读第004课:字典的实现01

这是Redis中我们碰到的第一个比较复杂的数据结构 字典部分预计共分三部分 第一部分, 也就是今天的视频, 是一个开场, 用手机录的, 把我自己对Redis中字典的设计逻辑给大家讲一讲 后两部分则才是真正的代码走读, 在代码层面细说字典的实现 今天的视频比较大, 时间却比较短..并且录到最后一部分的时候手机内存满了. 总共两个视频文件, 第二个视频文件只有几十秒. 大家凑合看吧 视频下载地址

Redis2.6源代码走读第004课:字典的实现03

字典中其它API的实现.. 下一讲可能要等几天, 或许不用等, 取决于我的工作效率与热情. 因为在Redis的数据结构中, 截止字典, 已经把设计组织最清晰的那部分讲完了. 接下来的数据结构部分是互相纠缠的. 我需要时间去分析一下. 视频下载地址