views:

59

answers:

2

alt text

how to rotate uibutton like this in iphone sdk.....

+3  A: 
theButton.transform = CGAffineTransformMakeRotation(-M_PI / 4);

(Note: π/4 = 45°.)

KennyTM
Nop ! please check - that makes wrong rotation - not as per sample image.
sugar
@sugar: Ah the UIKit coordinates is in the opposite direction. See update.
KennyTM
+1  A: 

If you have an IBOutlet Object.

theButton.transform = CGAffineTransformMakeRotation((22.0/7.0) / -4);

If you want to create run time button on view.

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn setFrame:CGRectMake(100, 100, 200, 44)];
    btn.transform=CGAffineTransformMakeRotation((22.0/7.0) / -4);
    [btn setTitle:@"RakeshBhatt" forState:UIControlStateNormal];
    [self.view addSubview:btn];
}
sugar
Thnx my frnd...
RakeshBhatt
Why don't you just use `M_PI` :/
Douwe Maan