如何旋转UITableViewCellAccessoryDisclosureIndicator?

Ale*_*xis 6 uitableview ios

我正在UITableView使用ios应用程序的可扩展/可折叠单元格.我UITableViewCellAccessoryDisclosureIndicator在这些细胞上放了一个,但是当细胞扩张/折叠时,我想让箭头向上/向下.

我发现可以制作一个带有自定义图像的按钮,并根据单元格的状态更改按钮,但它看起来很脏,因为我不需要那里的按钮,我必须在项目中添加2个图像(好吧,不管怎样,不是那么大).

那么简单地旋转现有的不应该更好 UITableViewCellAccessoryDisclosureIndicator吗?如果是这样我怎么能这样做?

Jef*_*mas 8

这不是你想要的,但这是我想到的第一件事.首先,实例化UIButtonTypeDetailDisclosure类型的按钮:

UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
Run Code Online (Sandbox Code Playgroud)

接下来,将按钮旋转90度:

CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform, DegreesToRadians(90));
button.transform = rotationTransform;
Run Code Online (Sandbox Code Playgroud)

最后,使用按钮作为accessoryView:

cell.accessoryView = button;
Run Code Online (Sandbox Code Playgroud)

希望有所帮助.

  • 神奇的答案 - 现在在iOS7中烦人,UIButtonTypeDetailDisclosure是愚蠢的"帮助符号"! (7认同)
  • `button.transform = CGAffineTransformMakeRotation(M_PI/2.0f);`有点整洁. (3认同)