我添加一堆UILabel视图到UITableViewCell的contentView,其中一些可以重叠.在点击任何标签时,我想触发一些动作.另外,我想将点击标签调到顶部.
在标签上使用UITapGestureRecognizer,我可以找出哪个被点击并执行操作.但是将轻拍和重叠的标签放在前面是行不通的.这就是我想要的:
UILabel *foundLabel = ....; // find the label
for (UITableViewCell *acell in theTable.visibleCells) {
UIView *cellContentView = acell.contentView;
if ([cellContentView.subviews containsObject:foundLabel]) {
[cellContentView bringSubviewToFront:foundLabel];
NSLog(@"should bring to front...");
}
}
Run Code Online (Sandbox Code Playgroud)
我确实得到了NSLog上面的输出,所以我知道bringSubviewToFront正在调用适当的单元格contentView.但是子视图布局顺序没有变化.
想法?
yea*_*xon 14
要探索的一件事是在uitablviewcell层上进行zposition.
这成功地将tableviewcell放在另一个面前为我:
cell1.layer.zPosition=3 ;//above
cell2.layer.zPosition=2 ;//below
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3941 次 |
| 最近记录: |