1

いくつかのテキストを a に表示していますCATextLayerが、大きすぎて定義された四角形に収まりません。すべてが読めるように、テキストをゆっくりと回転させたいと思います。私はそれを行う方法がわかりません。私はこれを行うための比較的簡単な方法があることを望んでいます.

    CATextLayer *label = [[CATextLayer alloc] init];
    NSRect labelRect;
    labelRect.origin.x = 20;
    labelRect.origin.y = -height / 3.5;
    labelRect.size.width = width - 40;
    labelRect.size.height = height;
    [label setFont:@"Helvetica-Bold"];
    [label setFontSize: fontSize];  
    [label setFrame:labelRect];
    [label setString:@"Some really long menu item that won't fit"];
    [label setAlignmentMode:kCAAlignmentLeft];
    [label setForegroundColor:whiteColor];

更新:私が説明しようとしているのは、テキスト自体が回転することだと思います。html マーキー タグのようなもので十分です。

4

1 に答える 1

1

これは私にとってはうまくいきました。これを試すのに役立ちます....

CGFloat radians = atan2f(_userResizableView2.transform.b, _userResizableView2.transform.a);

CGFloat flip=((UITextView*)_userResizableView2.contentView).transform.a;
NSLog(@"Flip x: %f Y : %f",((UITextView*)_userResizableView2.contentView).transform.a,((UITextView*)_userResizableView2.contentView).transform.b);
CGFloat degrees = radians * (180 / M_PI);
NSLog(@"Degree :%f",degrees);
float radiansToRotate = DEGREES_TO_RADIANS( -degrees );
CATransform3D zRotation;
zRotation = CATransform3DMakeRotation(radiansToRotate,0, 0, 1.0);
titleLayer.transform = CATransform3DScale(zRotation,flip, 1, 1);
于 2016-07-15T06:48:29.603 に答える