how to rotate uibutton like this in iphone sdk

Rakesh Bhatt picture Rakesh Bhatt · Jul 16, 2010 · Viewed 10.2k times · Source

alt text

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

Answer

Sagar R. Kothari picture Sagar R. Kothari · Jul 16, 2010

If you have an IBOutlet Object.

theButton.transform = CGAffineTransformMakeRotation(M_PI / -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(M_PI / -4);
    [btn setTitle:@"RakeshBhatt" forState:UIControlStateNormal];
    [self.view addSubview:btn];
}