为什么一个按钮与另一个重叠?

时间:2016-01-03 05:41:40

标签: ios swift

我有以下layoutSubViews()功能,它定位了两个按钮:

override func layoutSubviews() {
    let smallButtonSize = Int(frame.size.height)
    let largeButtonSize = Int(frame.size.height * 2)

    var smallButtonFrame = CGRect(x: 0, y: 0, width: 45, height: 45)
    var largeButtonFrame = CGRect(x: 0, y: 0, width: 45, height: 45)

    smallButtonFrame.origin.x = CGFloat(smallButtonSize)
    smallButton.frame = smallButtonFrame

    largeButtonFrame.origin.x = CGFloat(largeButtonSize)
    largeButton.frame = largeButtonFrame
}

问题是,出于某种原因这样做会导致"大"按钮不响应触摸。如果我将它的y原点放置得相当低,它就会开始响应触摸。

有什么关于"小"与"大"重叠的按钮按钮并阻止它响应触摸?

0 个答案:

没有答案