我是iOS开发新手并尝试创建一个自定义UITableViewCell,其背景为左上角和左下角我要圆,但它只适用于左上角。
这是我的代码(Swift 3):
override func awakeFromNib() {
super.awakeFromNib()
let bgViewMask = CAShapeLayer()
let bgViewPath = UIBezierPath(
roundedRect: bgView.bounds,
byRoundingCorners: [.topLeft, .bottomLeft],
cornerRadii: CGSize(width: 8, height: 8)
)
bgViewMask.frame = bgView.bounds
bgViewMask.path = bgViewPath.cgPath
bgView.layer.mask = bgViewMask
}
我也在layoutSubviews()
中尝试了这个override func layoutSubviews() {
super.layoutSubviews()
//code here
}
但它也不起作用。
如果我使用bgView.layer.cornerRadius = 8
,它适用于所有角落。
我做错了吗?
答案 0 :(得分:3)
你可以试试这个:
array.flat_map { |item| Array.new(5, item) }
[
[ 0] "A",
[ 1] "A",
[ 2] "A",
[ 3] "A",
[ 4] "A",
[ 5] "B",
[ 6] "B",
[ 7] "B",
[ 8] "B",
[ 9] "B",
[10] "C",
[11] "C",
[12] "C",
[13] "C",
[14] "C"
]