Maktub_Wiki Maktub_Wiki
主站 (opens new window)
  • 服务搭建
  • 网络服务
  • 开源框架
  • 操作系统
  • iOS/MacOS
  • 算法导论(Python)
  • Leetcode
  • 线性代数
主站 (opens new window)
  • 服务搭建
  • 网络服务
  • 开源框架
  • 操作系统
  • iOS/MacOS
  • 算法导论(Python)
  • Leetcode
  • 线性代数
  • UI相关

    • UITableView
    • C_C++库编译

      • libarchive静态库
    • iOS
    • UI相关
    Maktub_小明
    2024-01-05
    目录

    UITableView

    # 取消Header悬停

    自定义Section Header头部UIView

    public class MASectionNoHoverHeaderView: UIView
    {
        weak var tableView:UITableView?
        var section:Int = 0
    
        public override var frame: CGRect {
            didSet {
                if let tableView = tableView {
                    super.frame = tableView.rectForHeader(inSection: section)
                }
            }
        }
    }
    

    # Section分组圆角和设置下划线

    设置tableView的两个参数,才能设置separator

    tableView.separatorInset = .zero
    tableView.layoutMargins = .zero
    

    继承UITableViewCell,设置cell左右间距

    public class MAAutoWidthCell:UITableViewCell{
        public override var frame: CGRect{
            didSet{
                var newFrame = frame
                newFrame.origin.x = 16
                newFrame.size.width = UIScreen.width - 32
                super.frame = newFrame
            }
        }
    }
    

    通过UITableViewDelegate,设置圆角,和设置下划线缩进

    public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        let count = self.tableView(tableView, numberOfRowsInSection: indexPath.section)
        cell.layer.cornerRadius = 8
        cell.clipsToBounds = true
        cell.layer.maskedCorners = []
        if indexPath.row == 0 {
            cell.layer.maskedCorners.update(with: [.layerMinXMinYCorner, .layerMaxXMinYCorner])
        }
        cell.separatorInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0)
        if indexPath.row == count - 1 {
            cell.layer.maskedCorners.update(with: [.layerMinXMaxYCorner, .layerMaxXMaxYCorner])
            cell.separatorInset = UIEdgeInsets(top: 0, left: cell.frame.width, bottom: 0, right: 0)
        }
    }
    
    上次更新: 2025/03/22, 03:52:10
    libarchive静态库

    libarchive静态库→

    Theme by Vdoing | Copyright © 2021-2025 Maktub_小明 | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式