由文字生成path后制作写字的动画
{
NSAttributedString *attributed = self.attributedText;
CGMutablePathRef letters = CGPathCreateMutable();
CTLineRef line = CTLineCreateWithAttributedString((__bridge CFAttributedStringRef)attributed);
CFArrayRef runArray = CTLineGetGlyphRuns(line);
for (CFIndex runIndex = 0; runIndex < CFArrayGetCount(runArray); runIndex++)
{
CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runArray, runIndex);
CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName);
for (CFIndex runGlyphIndex = 0; runGlyphIndex < CTRunGetGlyphCount(run); runGlyphIndex++)
{
CFRange thisGlyphRange = CFRangeMake(runGlyphIndex, 1);
CGGlyph glyph;
CGPoint position;
CTRunGetGlyphs(run, thisGlyphRange, &glyph);
CTRunGetPositions(run, thisGlyphRange, &position);
CGPathRef letter = CTFontCreatePathForGlyph(runFont, glyph, NULL);
CGAffineTransform t = CGAffineTransformMakeTranslation(position.x, position.y);
CGPathAddPath(letters, &t, letter);
CGPathRelease(letter);
}
}
UIBezierPath *path = [UIBezierPath bezierPathWithCGPath:letters];
CGRect boundingBox = CGPathGetBoundingBox(letters);
CGPathRelease(letters);
CFRelease(line);
[path applyTransform:CGAffineTransformMakeScale(1.0, -1.0)];
[path applyTransform:CGAffineTransformMakeTranslation(0.0, boundingBox.size.height)];
if (self.reversedAnimation) {
return [[path bezierPathByReversingPath] CGPath];
}
return [path CGPath];
}
由文字生成path后制作写字的动画的更多相关文章
- Python3+HTMLTestRunner+SMTP生成测试报告后发送邮件
在前一篇https://www.cnblogs.com/zhengyihan1216/p/11549820.html 中记录了如何生成html格式的报告, 这篇记录下怎么将测试报告通过邮件发出 1.对 ...
- JS动态生成表格后 合并单元格
JS动态生成表格后 合并单元格 最近做项目碰到表格中的单元格合并的问题,需求是这样的,首先发ajax请求 请求回来后的数据 动态生成表格数据,但是生成后如果编号或者(根据其他的内容)有相同时,要合并单 ...
- C# 中使用Image.FromFile(string path)后,提示该文件正在被另一进程使用XXX的问题
C# 中使用Image.FromFile(string path)后,提示该文件正在被另一进程使用XXX的问题 C# 中使用Image.FromFile(string path)后,提示该文件正在被另 ...
- itextsharp生成pdf后的直接打印问题
原文 itextsharp生成pdf后的直接打印问题 小弟这两天用itextsharp生成pdf文档,生成的pdf可以直接保存在指定路径的文件夹下,可是user不想保存,想要点一下button,就可以 ...
- java 图片生成缩略图后,转化成流
功能:图片生成缩略图后,转化成流 public class ImageUtils { /** * * @param in1 * 文件流 * @param uploadFileName * 文件名称 * ...
- .net 做工作流时,生成项目后工具箱里有关工作流的东西不显示解决方法
在做工作流模块时,遇到一个比较棘手的问题,那就是生成项目后工具箱里有关工作流的东西不显示,这个问题令人百思不得其解,经过查阅英文网站,终于找到解决方法: 把项目中的建模项目移除掉,再重新生成,奇迹出现 ...
- ssh-keygen -t rsa 生成密钥对后如何校验
ssh-keygen -t rsa 生成密钥对后如何校验一下呢ssh-keygen -y -f id_rsa > id_rsa.pub.tobecompared 然后对比一下id_rsa.pub ...
- 使用SpringBoot配置了 server.servlet.path后无效的解决方案
一.问题描述 使用SpringBoot配置了 server.servlet.path后无效,访问时无法通过:http://127.0.0.1:8080/app/hello.html 访问. 二.解决方 ...
- WPF编程,通过Path类型制作沿路径运动的动画一种方法。
原文:WPF编程,通过Path类型制作沿路径运动的动画一种方法. 版权声明:我不生产代码,我只是代码的搬运工. https://blog.csdn.net/qq_43307934/article/de ...
随机推荐
- 在linux下运行mongodb
一>下载 1.去mongodb官网下拉框中找到 linux =>RHEL 6 => Package Manager: 2.Instructions for installing wi ...
- Jsp页面,结果集分页和sql(top)分页的性能对比
jsp页面两种分页模式: 第一种: 结果集分页,主要代码见下面: ResultSet rs=stmt.executeQuery(sql); ResultSetMetaData md=rs.getMet ...
- 6.14 提取第n个分割的子串
问题:从字符串中提取出一个指定的.由分割符隔开的子字符串.create view v as select 'mo,larry,curly' as namefrom t1union allselect ...
- HDU多校Round 3
Solved:4 rank:268 C. Dynamic Graph Matching 状压DP一下 #include <stdio.h> #include <algorithm& ...
- 洛谷——P2171 Hz吐泡泡
P2171 Hz吐泡泡 题目描述 这天,Hz大大心血来潮,吐了n个不同的泡泡玩(保证没有重复的泡泡).因为他还要写作业,所以他请你帮他把这些泡泡排序成树(左子树<=根<右子树).输出它的后 ...
- APUE 文件和目录
文件和目录 Unix 所有的文件都对应一个 struct stat,包含了一个文件所有的信息. #include <sys/stat.h> struct stat { mode_t st_ ...
- radial profiles of mean streamwise velocity at X/D=3
matlab code: load aver_ux_array.dat; load z_array.dat; r=z_array(:,); r=r.' r_j=0.00125; r_nor=r/d; ...
- 洛谷 3870 [TJOI2009]开关
[题解] 线段树基础题.对于每个修改操作把相应区间的sum改为区间长度-sum即可. #include<cstdio> #include<algorithm> #include ...
- BZOJ 3894 Luogu P4313 文理分科 (最小割)
题目链接: (bzoj) https://www.lydsy.com/JudgeOnline/problem.php?id=3894 (luogu) https://www.luogu.org/pro ...
- Ajax学习总结(2)——Ajax参数详解及使用场景介绍
一.定义和用法 AJAX即"Asynchronous Javascript And XML"(异步JavaScript和XML),是指一种创建交互式网页应用的网页开发技术. AJA ...