在对CALayer的最简单使用中使用的是超类CALayer。在该示例上稍作改动,将图片替换为文字:
代码如下:
-(void)loadSimpleImageAnimation{
//创建层
CATextLayer *layer = [CATextLayer layer];
layer.string=@"Marshal";
layer.foregroundColor=[[UIColor blackColor] CGColor];
layer.bounds = CGRectMake(0, 0, 200,200);
layer.position = CGPointMake(1024/2 , 768/2);//层在view的位置
[self.view.layer addSublayer:layer];//将层加到当前View的默认layer下
[layer release];
}
本文介绍如何利用CATextLayer来在iOS应用中显示并定位文字。通过创建CATextLayer实例,设置其字符串属性和颜色,定义边界及位置,并将其添加到视图的图层中。
3793

被折叠的 条评论
为什么被折叠?



