美文网首页iOS 问答集合
iOS 发送消息插入一行如何保证不闪屏

iOS 发送消息插入一行如何保证不闪屏

作者: 船长_ | 来源:发表于2018-04-21 10:45 被阅读34次
extension UITableView {

    ///保证 insert row 不闪屏
    func insertRowsAtBottom(_ rows: [IndexPath]) {
        UIView.setAnimationsEnabled(false)
        CATransaction.begin()
        CATransaction.setDisableActions(true)
        self.beginUpdates()
        self.insertRows(at: rows, with: .none)
        self.endUpdates()
        self.scrollToRow(at: rows[0], at: .bottom, animated: false)
        CATransaction.commit()
        UIView.setAnimationsEnabled(true)
    }
}

相关文章

网友评论

    本文标题:iOS 发送消息插入一行如何保证不闪屏

    本文链接:https://www.haomeiwen.com/subject/geatlftx.html