[翻译] DFXCoreTextView
DFXCoreTextView
https://github.com/davefoxy/DFXCoreTextView
A CoreText wrapper for the formatting and display of scrollable text in columns. The helper class DFXCoreTextFont is used as a replacement for UIFont, providing many formatting options only available in CoreText.
对 CoreText 的封装,以柱状的方式且可以翻动来显示文本。DFXCoreTextFont 类是用来替换 UIFont 的,提供很多的配置供 CoreText 使用。

Installation
Just drag the "DFXCoreTextView" folder inside the project directory into your own project (tick "Copy items into destination groups' folder") and add the CoreText framework to your project's build phases.
把文件夹 DFXCoreTextView 拖到你的工程当中,并引入 CoreText 框架。
Usage
First, create an instance of the base view, DFXCoreTextView in either code or by setting a view inside a XIB to DFXCoreTextView. This is where all your text will be rendered. The view extends UIScrollView for pagination and scrolling however you're free to declare yourself as it's delegate.
首先,创建一个基本 view 的实例对象,DFXCoreTextView 既可以以代码的形式,或者以 XIB 的形式添加进基本的 view 当中。在 DFXCoreTextView 中,才是你所有文本被渲染的地方。DFXCoreTextView 扩展了 UIScrollView 的翻页功能,当然,你也可以在它的代理中进行设置。
Default options are in place for presentation however, for customisation, you currently have access to the following properties on an instance:
默认的选项,就是在合适的地方显示文本,然而,为了更好的定制性,你可以控制一个实例对象的几个属性:
@property (nonatomic, assign) int columnsPerPage;
@property (nonatomic, assign) CGPoint innerPadding;
@property (nonatomic, assign) float columnSpacing;
When it's all set up, assign text using:
当所有的都配置好了,你就可以赋予文本了:
- (void)setText:(NSString*)text;
Formatting Using DFXCoreTextFont
The DFXCoreTextFont class is the only way to format text or specific pieces of text in a DFXCoreTextView. It's essentially what you use instead of UIFont and it offers a few more attributes that only be achieved by using CoreText. Currently, the following properties are available:
DFXCoreTextFont 是唯一的你能够拿来格式化文本的类,或者对 DFXCoreTextView 中的某些文本进行格式化。其本质上是用来替换 UIFont 的,它提供了一些属性可供修改,但仅仅适用于 CoreText。目前,以下的一些属性你可以使用:
@property (nonatomic, copy) NSString *fontName;
@property (nonatomic, assign) float fontSize;
@property (nonatomic, assign) DFXTextAlignment textAlignment;
@property (nonatomic, strong) UIColor *textColor;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, strong) NSNumber *strokeWidth;
@property (nonatomic, assign) CGFloat lineSpacing;
@property (nonatomic, assign) BOOL underlined;
@property (nonatomic, assign) float kerning;
When you've created your DFXCoreTextFont instance, assign it to your text by using one of the following methods:
当你已经创建了DFXCoreTextFont 实例对象,用下面其中的一条方法来给你的文本设置字体。
- (void)setFont:(DFXCoreTextFont*)font;
- (void)setFont:(DFXCoreTextFont*)font forRange:(NSRange)range;
- (void)setFont:(DFXCoreTextFont*)font forOccurancesOfString:(NSString*)string comparisonMode:(DFXCTComparisonMode)comparisonMode;
Updating The View
Drawing and layout happens in drawRect: so if you're finding text not updating properly, remember to call setNeedsDisplay on your view.
布局与绘图都在 drawRect:方法中进行的,所以,如果你发现你的文本没有更新属性,记住,调用 setNeedsDisplay 来重绘你的 view。
Project Requirements
DFXCoreTextView uses ARC and some elements of 'Modern Objective-C' such as auto-synthesize which requires Xcode 4.4
DFXCoreTextView 使用 ARC,以及一些“最新OC”特性如 auto-synthesize 需要 Xcode 4.4。
[翻译] DFXCoreTextView的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- Pg188-2 覆盖 向上转型
package org.hanqi.array; public class DongWu { private String name; private String color; public Str ...
- swftools中的pdf2swf转换Error overflow ID 65535 解决办法
近几日因为项目需要在线转换pdf到swf实现电子期刊阅读,用到了这个工具,版本是:swftools-0.9.2.tar.gz 当然也遇到了很头疼的问题,那就是在转换pdf中色彩图形比较复杂的页时会抛出 ...
- MFC+WinPcap编写一个嗅探器之五(过滤模块)
这一节主要介绍如何获设置捕获过滤,这里的过滤是指在捕获前过滤 设置捕获过滤主要是在CFilterDlg中完成,也就是对应之前创建的设置过滤规则对话框,如图: 首先要根据用户的选择来生成一个合法的过滤规 ...
- Oracle截取字符串和查找字符串
oracle 截取字符(substr),检索字符位置(instr) case when then else end语句使用 收藏 常用函数:substr和instr 1.SUBSTR(string,s ...
- js判断某年某月有多少天
function getCountDays(ym) { var curDate = new Date(ym); /* 获取当前月份 */ var curMonth = curDate.getMonth ...
- OpenGL笔记<5> shader 调试信息获取 Debug
我们今天来讲调试信息,这个东西讲起来会比较无聊,因为都是一些函数调用,没啥可讲的,函数就是那样用的,不过其效果挺好玩的,同时在程序设计中也是很必要的,所以还是来写一下,不过,就是因为知识比较固定且简单 ...
- 如何快速分析出现性能问题的Linux服务器
Brendan Gregg曾经分享过当遇到一个系统性能问题时,如何利用登录的前60秒对系统的性能情况做一个快速浏览和分析,主要包括如下10个工具,这是一个非常有用且有效的工具列表.本文将详细介绍这些命 ...
- AORUS GA-Z270X-Gaming 5開箱
「AORUS」這個品牌名稱由埃及神祇荷魯斯(戰爭與狩獵之神)的名字衍生而成.荷魯斯通常被勾勒為獵鷹的形象,因此獵鷹的頭形被用作AORUS品牌的商標於2014年,本來只做為用在電競筆電及一些週邊方面,但 ...
- [ 原创 ] Java基础1--Java中super和this的用法和区别
许多同学在学习Java时分不清楚this和super的用法和区别,今天偶然发现一片加精的博文,看完内容准备自己也写下来积累一下 1.如果想在子类的构造方法中调用父类的构造方法,必须在子类的构造方法中使 ...
- Winform 串口通讯之读卡器
老板给我的第一个硬件就是一个读卡器, 说让我做一下试试,于是从网上查了查就写了出来,相当的简单. 但是后来还有一个地磅的串口通讯,我整整搞了一天. 在窗体类的构造函数中写入 Form.CheckFor ...
