[翻译] BezierString
BezierString

https://github.com/lvnyk/BezierString
Rendering NSAttributedStrings along arbitrary continuous UIBezierPaths
将富文本沿着贝塞尔曲线绘制.
Example

1. Create a bezier path and an attributed string 创建出贝塞尔曲线以及富文本
let bezierPath = UIBezierPath()
bezierPath.moveToPoint(CGPointMake(50, 50+150))
bezierPath.addCurveToPoint(CGPointMake(50+200, 50), controlPoint1: CGPointMake(50+10, 50+75), controlPoint2: CGPointMake(50+100, 50))
bezierPath.addCurveToPoint(CGPointMake(50+400, 50+150), controlPoint1: CGPointMake(50+300, 50), controlPoint2: CGPointMake(50+400-10, 50+75))
let attributedString = NSAttributedString(string: "Where did you come from, where did you go?", attributes: [
kCTFontAttributeName: CTFontCreateWithName("HelveticaNeue-UltraLight", 26, nil),
kCTForegroundColorAttributeName: UIColor.redColor().CGColor
])
2. Use the BezierString class 使用BezierString类
let bezierString = BezierString(bezierPath: bezierPath)
// generate an image
let img:UIImage! = bezierString.imageWithAttributedString(attributedString)
// or render onto a preexisting context
bezierString.drawAttributedString(attributedString, toContext: UIGraphicsGetCurrentContext())
UIBezierLabel
Alternatively, in place of UILabel, use a UIBezierLabel instance, assign a bezierString orbezierPath and use as a normal UILabel
需要注意的是,替换当前UILabel非常简单.使用UIBezierLabel的实体对象,然后给bezierPath赋值,其余地方使用起来跟正常UILabel一样.
// create a label, either in code or Interface Builder
let label = UIBezierLabel(frame: CGRectZero)
// set the properties
label.bezierPath = bezierPath
label.textAlignment = .Center
label.text = "Where did you come from, where did you go?"
label.sizeToFit()
[翻译] BezierString的更多相关文章
- 《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 ...
随机推荐
- MVC与MVVM设计模式理解
MVC设计模式(View和Model之间不能直接通信) MVC是一种架构模式,M表示Model,V表示视图View,C表示控制器Controller: Model负责存储.定义.操作数据.从网络中获取 ...
- C++字符串string类常用操作详解(一)【初始化、遍历、连接】
代码示例: #include <iostream> #include "string" using namespace std; //字符串初始化 void strIn ...
- java-forkjoin框架的使用
ForkJoin是Java7提供的原生多线程并行处理框架,其基本思想是将大任务分割成小任务,最后将小任务聚合起来得到结果.fork是分解的意思, join是收集的意思. 它非常类似于HADOOP提供的 ...
- Markdown编辑器-图形化
SELECT * from yffee_favourable_detail yfd LEFT JOIN yffee_favourable yf on yfd.minor_id = yf.major_i ...
- activiti 临时笔记mark
public class TenMinuteTutorial { public static void main(String[] args) { // Create Activiti process ...
- JavaScript文档对象模型
文档对象模型(Document Object Model, DOM)是W3C提出的用于访问和修改文档的接口. JavaScript设计的初衷是为Web提供交互功能,它通过DOM接口来访问和修改文档. ...
- 使用jdk压缩war包
首先安装jdk 压缩 ..../jdk/bin/jar -cvf file.war file 解压 ..../jdk/bin/jar -xvf file.war
- MYSQL安装时解决要输入current root password的解决方法
在装MYSQL的时候发现要输入current root password不记得以前在电脑里装过(你的系统曾经装过MYSQL在重装就会要求输入原来设定的密码,如果是第一次安装就不会出现),在网上苦苦搜寻 ...
- [javaSE] 位运算符(&|^)
位运算是直接对二进制进行计算 左移 << 右移 >> 先把整数换成四个8bit 0000-0000 0000-0000 0000-0000 0000-0000 这个二进制左右移 ...
- XCode 添加自定义framework运行时出现dyld: Library not loaded的解决方法
XCode添加自定义framework运行时出现dyld: Library not loaded的解决方法 在使用自定义的framework运行时,会出现如下的错误: dyld: Library no ...