我希望我的表格视图部分标题文本以充满活力的风格呈现,其中底层 UI 通过文本闪耀。我尝试了以下方法,但标题中没有出现任何内容,好像我返回了nil
.
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
//Add vibrancy text effect
let blurEffect = UIBlurEffect(style: .Light)
let vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect)
let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
//Label for vibrant text
let vibrantLabel = UILabel()
vibrantLabel.text = "testing"
vibrantLabel.font = UIFont.systemFontOfSize(11.0)
vibrantLabel.textColor = UIColor(white: 0.64, alpha: 1)
vibrancyEffectView.contentView.addSubview(vibrantLabel)
return vibrancyEffectView
}