我已经通过以下代码添加了图像,但无法达到期望的效果:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 50))
let image = UIImageView(frame: CGRect(x: 15, y: 10, width: 30, height: 30))
let section = self.sections[section]
switch section {
case .phone:
image.image = UIImage(systemName: "phone.fill")
break
case .mail:
image.image = UIImage(systemName: "message.fill")
break
case .company:
image.image = UIImage(systemName: "person.fill")
break
}
view.addSubview(image)
return view
}
我想要实现的演示
”>
我已经通过以下代码添加了图像,但无法按需实现:func tableView(_ tableView:UITableView,viewForHeaderInSection部分:Int)-> UIView? {let view = UIView(...
使用节标题无法实现此行为。我建议两个选择,