1
點擊按鈕,我想創建工具提示。 現在我正在得到一個矩形。在Swift中添加工具提示指針iOS
如何在下圖中添加指針?
下面就是我試圖像視圖爲您開發庫的列表創建工具提示
var ToolTipView = UIView()
func tooltip(){
for view in self.ToolTipView.subviews {
view.removeFromSuperview()
}
ToolTipView.removeFromSuperview()
ToolTipView.frame = CGRect(x:50, y:self.view.bounds.height-150, width:100, height:50)
ToolTipView.backgroundColor = UIColor(red:0, green:0, blue:0, alpha:0.7)
ToolTipView.layer.cornerRadius = 5.0
let txtLabel = UILabel(frame: CGRect(x:0, y:2, width:100, height:50))
txtLabel.text = "Click"
txtLabel.textAlignment = NSTextAlignment.Center
txtLabel.textColor = UIColor(red:1, green:1, blue:1, alpha:1)
txtLabel.font = UIFont(name:"HelveticaNeue", size: 16)
self.ToolTipView.addSubview(txtLabel)
self.view.addSubview(ToolTipView)
self.view.bringSubviewToFront(ToolTipView)
}
你需要自己動手 –