First, you can do it and it is fairly easy to do! Here is what it will look like!

There are two NSView methods available to do this.
In OS 10.0 you have:
- (void)setFrameRotation:(CGFloat)angle
And in OS 10.5 you have:
- (void)setFrameCenterRotation:(CGFloat)angle
For some the above information will be sufficient. For those desiring more information please continue to read this posting.

Name and save the project whatever you want. I named my project "RotatedControl".

I named my class "Controller"
Add your IBOutlets to your new class. Here is my code:

// Controller.h
// RotatedControl
//
// Created by Geoffrey_Slinker on 9/13/09.
// Copyright 2009 Area 51. All rights reserved.
//
#import
@interface Controller : NSObject {
IBOutlet NSTextField *textField;
IBOutlet NSButton *button;
}
@property (retain) NSTextField *textField;
@property (retain) NSButton *button;
- (void) awakeFromNib;
@end
//
// Controller.m
// RotatedControl
//
// Created by Geoffrey_Slinker on 9/13/09.
// Copyright 2009 Area 51. All rights reserved.
//
#import "Controller.h"
@implementation Controller
@synthesize textField;
@synthesize button;
- (void) awakeFromNib
{
//[textField setFrameRotation:45.0];
//[button setFrameRotation:30.0];
[textField setFrameCenterRotation:45.0];
[button setFrameCenterRotation:-45.0];
}
@end
Now open the NIB file. In XCode double click "MainMenu.xib" found in the folder "NIB Files". This should launch Interface Builder (IB).
Add an "Object Controller" and set its class to be the class type you created above. In my case I set it to "Controller". See "Where is the Classes Tab" for detailed information.
Still in IB add a Button and a Text Field to your Window. Just select them from the Library of Objects and drag them onto the Window.

Now "hook up" the IBOutlets of the Controller to the controls on the window.

Also wire the the "Referencing Outlets" delegate to the "Application". The "Application is above the "Controller" in the MainMenu.xib view.
If I haven't missed any steps then from XCode just build and run the application.