zl程序教程

您现在的位置是:首页 >  其它

当前栏目

BezierString

2023-09-14 08:57:30 时间

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()

 


编程中最难的就是命名?这几招教你快速上手 在项目中,从项目的创建到方法的实现,每一步都以命名为起点,我们需要给变量、方法、参数、类命名,这些名字出现在代码的每个角落,随处可见,混乱或错误的命名不仅让我们对代码难以理解,更糟糕的是,会误导我们的思维,导致对代码的理解完全错误。如果整个项目始终贯穿着好的命名,就能给阅读者一个神清气爽的开始,也能给阅读者一个好的指引。
带你深入React 18源码之:useMemo、useCallback和memo 在这篇文章中,我们将探讨useMemo、useCallback和memo的用法和区别,并通过源码分析来理解它们的工作原理,开整!
阿里云灵积模型服务Quick Start DashScope灵积模型服务以模型为中心,致力于面向AI应用开发者提供品类丰富、数量众多的模型选择,并为其提供开箱即用、能力卓越、成本经济的模型服务API。DashScope灵积模型服务依托达摩院等机构的优质模型,在阿里云基础设施之上构建。灵积服务4.11号刚刚开通公测,目前提供Paraformer语音识别API能力,后续通义千问也将通过该服务对外提供API能力。本文演示如何快速通过Python SDK接入服务。
0基础也能搭建个人网站! 哈喽大家好 ,我是小宇。之前做了一期0成本搭建个人网站的教程,准确来说是0经济成本,反响还不错。但是毕竟是0成本,受限太多,很多小伙伴想学习如何在服务器上搭建网站。正好大学期间,简单的搭建过一些网站,我又做了一些功课,今天小宇就教大家0基础在服务器上搭建属于自己的网站!废话少说,正片开始。
阿里云宣布ECS最新主售实例降价40% 全栈云产品开放免费试用 阿里云宣布ECS最新主售实例降价40%  全栈云产品开放免费试用 阿里云推出对象存储预留空间产品 价格最多降低70%
一种新的流:为Java加入生成器(Generator)特性 一种全新的设计模式,数学美感与工程实用价值兼备,且不限编程语言。本文将以Java为样例,从无到有实现出完整的流式API,引入生成器特性,并介绍诸多应用场景。