gpt4 book ai didi

ios - 向 UIView 添加圆角会禁用 touchesBegan

转载 作者:行者123 更新时间:2023-11-28 08:53:55 24 4
gpt4 key购买 nike

我通过这种方式向我的 UIView 添加了底部圆角:

let maskLayer = CAShapeLayer()
maskLayer.path = UIBezierPath(roundedRect: bounds, byRoundingCorners: [.BottomLeft, .BottomRight], cornerRadii: CGSizeMake(20, 20)).CGPath
self.layer.mask = maskLayer

以前是这样的:enter image description here

之后:enter image description here

有两个问题。底部的第一个图像消失了,第二个是未调用 touchesBegantouchesMoved 等。

图像有 3 个约束:

enter image description here

最佳答案

另一种圆角方法(对我来说从来没有导致这些问题)是将这两种方法应用于您的 View :

myView.clipsToBounds = true
myView.layer.cornerRadius = 5 (play with this to get what you want!)

关于ios - 向 UIView 添加圆角会禁用 touchesBegan,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33583584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com