Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

ios - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...