Swift3.0 Swift中cell分割线靠左对齐,cell基类封装
来源:互联网 发布:关口知宏 对中国评价 编辑:程序博客网 时间:2024/06/05 17:04
一:如OC一样,swift中cell的分割线也是默认缺了左边一点,那么如何让分割线左对齐呢
1.那么我们在自定义cell的基类中设置下,那么以后的cell都继承基类,以后都不会有分割线问题了
import UIKitclass SCYBaseTableViewCell: UITableViewCell { override func awakeFromNib() { super.awakeFromNib() initCell() } override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state } required init?(coder aDecoder:NSCoder) { super.init(coder: aDecoder) } override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) initCell() } private func initCell(){ self.selectionStyle = .gray if self.responds(to:#selector(setter: UIView.layoutMargins)) { self.layoutMargins = UIEdgeInsets.zero } if self.responds(to: #selector(setter: UITableViewCell.separatorInset)) { self.separatorInset = UIEdgeInsets.zero } }}总结下就是这段代码很重要
if self.responds(to:#selector(setter: UIView.layoutMargins)) { self.layoutMargins = UIEdgeInsets.zero } if self.responds(to: #selector(setter: UITableViewCell.separatorInset)) { self.separatorInset = UIEdgeInsets.zero }
override func viewDidLoad() { super.viewDidLoad() if tableView.responds(to:#selector(setter: UITableViewCell.separatorInset)) { tableView.separatorInset = UIEdgeInsets.zero } if tableView.responds(to:#selector(setter: UIView.layoutMargins)) { tableView.layoutMargins = UIEdgeInsets.zero }
}
阅读全文
0 0
- Swift3.0 Swift中cell分割线靠左对齐,cell基类封装
- cell分割线左对齐
- iOS7 cell分割线左对齐
- cell让分割线左对齐
- iOS7 tableview separatorInset cell分割线左对齐
- cell分割线左对齐,不起作用?用下边的方法
- iOS7 tableview separatorInset cell分割线左对齐
- iOS7 tableview separatorInset cell分割线左对齐
- IOS-52-UITableView中cell分割线左对齐(解决iOS8版本适配问题)
- iOS8 tableview separatorInset cell分割线左对齐,ios7的方法失效了
- 自定义cell分割线
- TableView cell 分割线
- cell的分割线
- UITableViewCell中cell分割线不显示
- iOS中如何去掉cell分割线
- iOS中 自定义cell分割线/分割线偏移
- iOS7 tableview separatorInset cell分割线左对
- UITableView中cell线条的自定义 表格分割线(swift OC)
- poj 3070 Fibonacci,不用打表的快速斐波那契
- Python ML环境搭建与学习资料推荐
- python常用语法
- 修改z-stack LED引脚出现引脚不可控
- hdu6092 Rikka with Subset(母函数+思维)
- Swift3.0 Swift中cell分割线靠左对齐,cell基类封装
- 网易笔试:买苹果
- oracle中逻辑与、逻辑或、逻辑与非函数的使用
- 自然语言理解应用API对比报告
- 南阳OJ-题目96 n-1位数【语言入门】
- scala中的函数和方法
- Java面试集锦
- 切片上传/视频
- 每日一题(25)—— 自加++