iPhone Table View 单元格 - 角三角形

标签 iphone ios tableviewcell

有没有人看到过在 tableview 单元格中绘制角三角形的代码片段(或类/库)(见下图)。

enter image description here

最佳答案

您可以从图像创建新 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/

相关文章:

javascript - jquery 绑定(bind)事件不会在手机上触发

iPhone/Cocoa Touch - 将 UITableViewCell 背景从一种颜色更改为另一种颜色

iphone - 防止触摸传播到下面的注释

iphone - 移动文档文件夹的路径?

javascript - 如何使用 wkwebview 从 swift 返回 bool 值到 javascript 函数

ios - 无法从我的 iOS 10 应用程序打开 App Store 中的评级页面

ios - 淡出披露指示符

swift - 如何使用 Swift 在 uitableViewCell 中启动 ActivityIndi​​cator 的动画?

swift - UITableViewAutomaticDimension 不适用于调整单元格高度

iphone - 如何在 web View 中以编程方式添加带有后退和第四个按钮的工具栏以在 iphone 中导航?