【问题标题】:Swift: How to design cell view as two triangles?Swift:如何将单元格视图设计为两个三角形?
【发布时间】:2018-09-06 11:18:42
【问题描述】:

如何制作两个三角形的单元格,或者两个半边之间有对角线的单元格。

我目前使用这里建议的解决方案 How to set two colors in UIButton background 但这并不是我所需要的,因为我需要在两者之间留出一点白色或透明的空间,例如:http://i66.tinypic.com/np5dex.png

【问题讨论】:

  • 您可以很容易地修改链接到的代码以使用第三种颜色来实现这些“三角形”之间的间距。
  • 创建一个与背景颜色相同的视图。为视图设置宽度等于pythagoras,将其旋转一半pi

标签: ios swift uitableview uicollectionview uicollectionviewcell


【解决方案1】:

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

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]

【讨论】:

    猜你喜欢
    • 2023-03-19
    • 2021-05-08
    • 1970-01-01
    • 2023-02-04
    • 1970-01-01
    • 2011-09-30
    • 2020-09-12
    • 1970-01-01
    • 2015-01-06
    相关资源
    最近更新 更多