cuốn sách gpt4 ai đã làm

ios - 如何防止 UILabel 阻止触摸 Swift 中的父 UIButton?

In lại Tác giả: Walker 123 更新时间:2023-11-28 09:33:08 25 4
mua khóa gpt4 Nike

我有一个 UIButton,它有四个子 UILabel,其中包含有关按钮功能的信息。当我单击按钮的中心时,操作不会触发,因为它被 UILabels 阻止,但是当我单击按钮的外部时,操作会触发。有没有办法防止 UILabels 阻止 Action 触发?

câu trả lời hay nhất

您需要在按钮上方的任何 View 或其 subview 上设置 isUserInteractionEnabled = false.

mặc định UILabel 将其设置为 SAI,但正如您在评论中提到的,UIStackView 没有。所以调用 isUserInteractionEnabled = false 就可以了 ┌( ಠ‿ಠ)┘

关于ios - 如何防止 UILabel 阻止触摸 Swift 中的父 UIButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42477087/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress