我想更改我的表格視圖頁腳中的按鈕文字顏色。下面是我使用的代碼,但它不工作以編程方式設置UIButton文本顏色
override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let footerView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 40))
footerView.backgroundColor = UIColor.blackColor()
let rgbValue = 0x4097d4
let color = Util.getColor(rgbValue)
let button = UIButton(type: UIButtonType.System) as UIButton
button.frame = CGRectMake(0, 0, 414, 65)
button.setTitle("my Button", forState: UIControlState.Normal)
button.titleLabel?.textColor = UIColor.whiteColor()
button.titleLabel?.font = UIFont(name: "Montserrat-Regular", size: 20.0)
button.backgroundColor = UIColor(red: CGFloat(color[0]), green: CGFloat(color[1]), blue:CGFloat(color[2]), alpha: 1.0)
footerView.addSubview(button)
return footerView
}
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 40.0
}
一個問題是,文本顏色不會改變,另一個問題是,我有很多的靜態行的在我的tableview。我正在固定底部的按鈕,但問題是屏幕到達底部時,如果我點擊屏幕並在上方拖動屏幕,它仍然在按鈕後顯示一些空白空間
嘗試了其他類型的'UIButtonType'? –
@TravisGriggs nope – hellosheikh