UI: 容器视图
Container,
非常的有用。
对的
//tabbar背景视图
private var bgView: UIView?
func clickBtn(curBtn: UIButton) {
//1.取消之前选中按钮的状态
let lastBtnView = bgView!.viewWithTag(300+selectedIndex)
if let tmpBtn = lastBtnView {
//上次选中的按钮
let lastBtn = tmpBtn as! UIButton
let lastView = tmpBtn.viewWithTag(400)
if let tmpLabel = lastView {
//上次选中的标签
let lastLabel = tmpLabel as! UILabel
lastBtn.selected = false
lastLabel.textColor = UIColor.grayColor()
}
}
//2.设置当前选中按钮的状态
let curLabelView = curBtn.viewWithTag(400)
if let tmpLabel = curLabelView {
let curLabel = tmpLabel as! UILabel
curBtn.selected = true
curLabel.textColor = UIColor.orangeColor()
}
//3.选中视图控制器
selectedIndex = curBtn.tag - 300
}
崩的
func clickBtn(curBtn: UIButton) {
//1.取消之前选中按钮的状态
let lastBtnView = self.view.viewWithTag(300+selectedIndex) //看这里
if let tmpBtn = lastBtnView {