如何旋转UITableViewCellAccessoryDisclosureIndicator? [英] How to rotate UITableViewCellAccessoryDisclosureIndicator?

查看:70
本文介绍了如何旋转UITableViewCellAccessoryDisclosureIndicator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为ios app制作一个带有可展开/可折叠单元格的 UITableView 。我在这些单元格上放了一个 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.

我发现可以制作一个带有自定义图像的按钮,并根据单元格的状态更改按钮,但它对我来说似乎很脏,因为我不需要按钮,我必须添加2个图像到项目(好吧,它不是那么大,但无论如何)。

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).

因此,简单地旋转现有的 UITableViewCellAccessoryDisclosureIndicator 是不是更好?如果是这样我怎么能这样做?

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

推荐答案

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

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];

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

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;

希望有所帮助。

这篇关于如何旋转UITableViewCellAccessoryDisclosureIndicator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆