ios - Swift:如何将单元格 View 设计为两个三角形?

标签 ios swift uitableview uicollectionview uicollectionviewcell

如何制作带有两个三角形或中间有对角线的两半单元格。

我目前使用此处建议的解决方案 How to set two colors in UIButton background但这并不是我所需要的,因为我需要中间有一点白色或透明的空间,如下所示:http://i66.tinypic.com/np5dex.png

最佳答案

您也可以使用链接的渐变解决方案。您需要做的就是添加更多的渐变停止点,这样渐变的中间就会有一个白色/透明的部分。玩这样的东西

gradient.colors = [
    UIColor.orange.cgColor,
    UIColor.orange.cgColor,
    UIColor.clear.cgColor,
    UIColor.clear.cgColor,
    UIColor.green.cgColor,
    UIColor.green.cgColor,
]
gradient.locations = [0, 0.4, 0.4, 0.6, 0.6, 1.0]

关于ios - Swift:如何将单元格 View 设计为两个三角形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52202914/

相关文章:

iphone - 在自定义 UITableViewCell 中调整 UIImageView 的大小会产生不一致的结果

javascript - html存储safari隐身模式,angular2

ios - 导航 Controller 自定义过渡动画

ios - 带 : Stripping frameworks fatal error: lipo: -remove's specified would result in an empty fat file 的 Realm 框架错误

c - 在 SwiftUI 中,我如何创建一个将项目添加到 ScrollView 的函数?

ios - 具有多个页面的 UITableViewController 和 ContentViewController 之间的交换日期

ios - 解析云代码调用中突然崩溃

swift - 如何在 macOS 上将 iPhone 设为 AVCaptureDevice?

Swift 对成员 '==' 的模糊引用

ios - 使用多线程从多个表并行加载大数据