Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to rotate uibutton like this in iphone sdk

alt text

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

like image 582
Rakesh Bhatt Avatar asked Dec 03 '22 12:12

Rakesh Bhatt


2 Answers

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];
}
like image 158
Sagar Kothari Avatar answered Dec 14 '22 07:12

Sagar Kothari


theButton.transform = CGAffineTransformMakeRotation(-M_PI / 4);

(Note: π/4 = 45°.)

like image 27
kennytm Avatar answered Dec 14 '22 07:12

kennytm