我查看了苹果发布的新 UI 信息 - 没有帮助。
现在让代码和截图来展示我遇到的问题。为了确保不是我的有 bug 的代码,我创建了一个新项目,只包含一个文件 - 一个内部有 tableView 的 UIViewController,委托已经设置好。
我做了以下操作:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"UITableViewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:@"%d",indexPath.row];
// Configure the cell...
UIView * redView = [[UIView alloc] initWithFrame:CGRectMake(0, -10, 100, 20)];
redView.backgroundColor = [UIColor redColor];
[cell addSubview:redView];
return cell;
}
表格视图设置为分组。 让我们在iOS 6上运行它: 当然,Y坐标原点是负数! 是的,确实如此,这就是我想要实现的结果。 让我们看看在iOS 7上会显示什么: 提示:如果我们将redView添加到普通的UIView中,则不会发生这种情况。
另一个提示:如果我将tableView的背景颜色设置为蓝色,则分区之间的灰色线条将变为蓝色,而不是灰色(以演示灰色不是设置的标题)。 另一个提示:iPad也是如此。
为什么在iOS 7中会裁剪超出边界的所有内容?请帮忙!
clipsToBounds
属性设置为NO吗? - Michał Zygar