• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 如何制作UILabel Objective c的弯曲文本

[复制链接]
菜鸟教程小白 发表于 2022-12-13 11:36:22 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我想制作 UILabel 的弯曲文本。如何实现这个?

enter image description here

到目前为止,我的标签代码是:

UILabel *loveLabel = [[UILabel alloc]init];
loveLabel.frame = CGRectMake(20, 50, 50, 50);
loveLabel.text = @"Flowers";
loveLabel.textAlignment = NSTextAlignmentCenter;
loveLabel.layer.cornerRadius = 25;
loveLabel.layer.masksToBounds = YES;
[self.view addSubview:loveLabel];



Best Answer-推荐答案


You can download a sample project that use CoreTextArcView:    

github

导入“CoreTextArcView.h”并在viewdidload中添加代码

CGRect rect1 = CGRectMake(0, 120, 320, 120);
UIFont * font1 = [UIFont fontWithName"Helvetica" size:26.0f];
UIColor * color1 = [UIColor whiteColor];
CoreTextArcView * cityLabel = [[[CoreTextArcView alloc] initWithFrame:rect1
                                                                font:font1
                                                                text"New York City"
                                                              radius:85
                                                             arcSize:110
                                                               color:color1] autorelease];
cityLabel.backgroundColor = [UIColor clearColor];


CGRect rect2 = CGRectMake(0, 235, 320, 200);
CoreTextArcView * cityLabel2 = [[[CoreTextArcView alloc] initWithFrame:rect2
                                                                 font:font1
                                                                 text"Google"
                                                               radius:-80
                                                              arcSize:-80
                                                                color:color1] autorelease];

[cityLabel2 showsLineMetrics];
cityLabel2.backgroundColor = [UIColor clearColor];

[self.view addSubview:cityLabel];
[self.view addSubview:cityLabel2];

关于ios - 如何制作UILabel Objective c的弯曲文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33341405/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap