Access iOS 7 hidden UITableViewCellScrollView?
Apple 更改 iOS 7 中的 UITableViewCell 层次结构
使用 iOS 6.1 SDK
|
1
2 3 |
<UITableViewCell>
| <UITableViewCellContentView> | | <UILabel> |
使用 iOS 7 SDK
|
1
2 3 4 |
<UITableViewCell>
| <UITableViewCellScrollView> | | <UITableViewCellContentView> | | | <UILabel> |
我的问题是 UITableViewCellScrollView.layer.masksToBounds = TRUE 默认情况下,我需要它是假的。
我尝试了以下方法:
|
1
2 |
UIView * scrollView = [self.subviews objectAtIndex:0];
scrollView.layer.masksToBounds = NO; |
和
|
1
|
[self.myLabel.superview.layer setMasksToBounds:NO];
|
但他们都没有改变UITableViewCellScrollView。
如何访问此滚动视图?
访问新 CellScrollView 的唯一方法是在创建单元格超级视图后访问它。
我添加了以下 cellForRowAtIndexPath:
|
1
2 3 |
cell = [[UICustomTableViewCell alloc] init];
UIView *cellScrollView = cell.myLabel.superview; [cellScrollView.layer setMasksToBounds: NO]; |
我认为 Apple 应该为我们提供一种无需黑客攻击即可访问此新 ScrollView 的方法。
目标-C:
|
1
2 |
UIView *cellScrollView = [[cell contentView] superview];
[cellScrollView setClipsToBounds:NO]; |
斯威夫特:
|
1
2 |
let cellScrollView = cell.contentView.superview
cellScrollView?.clipsToBounds = false |
来源:https://www.codenong.com/19162725/
