Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate UITableViewCellAccessoryDisclosureIndicator?

I'm making a UITableView with expandable/collapsable cells for ios app. I put a UITableViewCellAccessoryDisclosureIndicator on these cells but I'd like to make the arrow headed up/down when the cell is expanded/collapsed.

I found that it's possible to make a button with a custom image and change the button according to the state of the cell but it seems dirty to me because I don't need a button there and I have to add 2 images to the project (ok it's not that big but anyway).

So shouldn't it be better to simply rotate the existing UITableViewCellAccessoryDisclosureIndicator ? and if so how can I do that?

like image 357
Alexis Avatar asked Jun 27 '12 08:06

Alexis


1 Answers

This is not exactly what you want, but this the first thing I thought of. First, instantiate a button of type UIButtonTypeDetailDisclosure:

UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

Next, rotate the button 90 degrees:

CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform, DegreesToRadians(90));
button.transform = rotationTransform;

Finally, use the button as the accessoryView:

cell.accessoryView = button;

Hope that helps.

like image 198
Jeffery Thomas Avatar answered Sep 19 '22 10:09

Jeffery Thomas