iOS 3D label 开发
2016-12-14 本文已影响0人
陈贺
本人参考了简书原作者的代码
大家可以根据链接https://github.com/XJALYN/3DText
下载查看项目源码
拖进作者项目中重新创建的label类到自己创建的项目中

然后添加下面的代码就能实现
- (void)viewDidLoad {
[super viewDidLoad];
OS3DLabel *label = [[OS3DLabel alloc]initWithFrame:CGRectMake(0, 10, self.view.bounds.size.width, 100)];
/// 是否可以控制
label.allowsControl = true;
/// 设置
label.backgroundColor = [UIColor purpleColor];
/// 单行显示
label.isSingle = YES;
/// 设置字体的大小
label.fontSize = 2;
/// 设置文字内容
label.text = @"趣动课堂";
/// 设置尾部省略模式
label.truncationMode = kCATruncationMiddle;
/// 设置对其方式
label.alignmentMode = kCAAlignmentCenter;
/// 设置深度
label.depth = 0.5;
/// 设置填充内容
label.contents = [UIImage imageNamed:@"1.png"];
/// 设置颜色
label.textColor = [UIColor greenColor];
/// 设置环境场景
label.scene.background.contents = @"skybox01_cube.png";
[self.view addSubview:label];
根据这些属性设置完成3D label的开发,大家了解下。
下面是图片效果

