有没有人看到过在 tableview 单元格中绘制角三角形的代码片段(或类/库)(见下图)。
最佳答案
您可以从图像创建新 View ,然后将其添加到调用 addSubview 的单元格中。这是在启动时设置角的示例:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
CGRect cornerFrame = CGRectMake(x, y, width, height);
UIImageView * corner = [[UIImageView alloc] initWithFrame:cornerFrame];
[corner setImage:[UIImage imageNamed:@"corner.jpg"]];
[cell.contentView addSubview:corner];
}
return cell;
}
关于iPhone Table View 单元格 - 角三角形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8362841/