在我的应用中,我使用SwiftCharts
lib来创建一些图表,如:
您可以在图片中看到,当用户点按图表中的点时,我会创建BubbleInfo
视图,然后在UIButton
视图中添加BubbleInfo
,代码如下:< / p>
bubbleView.transform = CGAffineTransform(scaleX: 0, y: 0).concatenating(CGAffineTransform(translationX: 0, y: 100))
let infoView = UILabel(frame: CGRect(x: 0, y: 10, width: w, height: h - 30))
infoView.textColor = UIColor.white
infoView.backgroundColor = UIColor.black
infoView.text = "Some text about \(chartPoint)"
infoView.font = ExamplesDefaults.fontWithSize(Env.iPad ? 14 : 12)
infoView.textAlignment = NSTextAlignment.center
//create button
let btn = UIButton(frame: infoView.bounds)
btn.backgroundColor = UIColor.red.withAlphaComponent(0.5)
btn.addTarget(weakSelf, action: #selector(weakSelf.btnTapped(_:)), for: .touchUpInside)
bubbleView.addSubview(infoView)
bubbleView.addSubview(btn)
但是当我点击按钮时,什么也没发生!
它有什么问题?
我该怎么办呢?
谢谢;)