Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rotate an NSTextField on OS X?

Tags:

macos

ios

cocoa

Does OS X have an equivalent of [UIView setTransform:] on iOS? I have an NSTextField that I want to rotate 10 degrees. In iOS I’d just use [UILabel setTransform:]. Is there anything equivalent for Cocoa Framework?

like image 377
Dave Leverton Avatar asked Dec 06 '22 06:12

Dave Leverton


2 Answers

frameRotation or frameCenterRotation should do that

like image 191
wattson12 Avatar answered Dec 10 '22 13:12

wattson12


You could use the underlying layer and rotate that

myView.wantsLayer = YES;
myView.layer.transform = CATransform3DMakeRotation(angle, 0, 0, 1);

p.s. Remember to import QuartzCore

like image 40
David Rönnqvist Avatar answered Dec 10 '22 13:12

David Rönnqvist