Iphone 向UILabel添加倾斜文本

Iphone 向UILabel添加倾斜文本,iphone,objective-c,Iphone,Objective C,我需要以类似于的对角线角度添加一些文本(图像显示文本倾斜) 如何以编程方式将倾斜文本添加到UILabel中?您需要使用CGAffineTransform。 因为使用此选项将旋转标签,所以您可以执行以下操作 在您的.h文件中 UILabel *myLabel; 在你的.m文件中 如果要在开始时显示倾斜文本,请在viewdiload函数中写入下面的代码 myLabel.text=@"Hello world"; CGAffineTransform transformRotate = CGAffine

我需要以类似于的对角线角度添加一些文本(图像显示文本倾斜)


如何以编程方式将倾斜文本添加到
UILabel
中?

您需要使用
CGAffineTransform
。 因为使用此选项将旋转标签,所以您可以执行以下操作

在您的.h文件中

UILabel *myLabel;
在你的.m文件中 如果要在开始时显示倾斜文本,请在
viewdiload
函数中写入下面的代码

myLabel.text=@"Hello world";
CGAffineTransform transformRotate = CGAffineTransformMakeRotation((M_PI  * -90 / 180.0));
//above you can change the angle so that you can get the required rotation
myLabel.transform = transformRotate;

但是,在哪里添加文本或字符串“Example”。我需要“示例”来旋转,如何编辑上面的代码来旋转?