简体   繁体   English

Swift:如何将单元格视图设计为两个三角形?

[英]Swift: How to design cell view as two triangles?

How to make cell with two triangles, or two halfs with diagonal line in between. 如何用两个三角形或两个半角之间的对角线制作单元格。

I currently use solution advised here How to set two colors in UIButton background but it's not exactly what I need, since I need a little white or transparent space in between, like this: http://i66.tinypic.com/np5dex.png 我目前使用这里建议的解决方案如何在UIButton背景中设置两种颜色,但这并不是我真正需要的,因为我需要在它们之间留一点白色或透明空间,例如: http : //i66.tinypic.com/np5dex.png

You can use the gradient solution that you linked too. 您也可以使用链接的渐变解决方案。 All you need to do is add more gradient stops, so that there will be a white/transparent section in the middle of the gradient. 您需要做的就是添加更多渐变停止点,以便渐变中间会出现一个白色/透明部分。 Play around with something like this 玩这样的事情

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM