Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU消耗问题 #618

Closed
SPStore opened this issue Jan 7, 2024 · 1 comment
Closed

CPU消耗问题 #618

SPStore opened this issue Jan 7, 2024 · 1 comment

Comments

@SPStore
Copy link

SPStore commented Jan 7, 2024

平移手势选择相册的时候,CPU消耗较高。主要原因是平移过程中,这行代码导致:

        bottomView.updateFinishButtonTitle()

这个方法中不断的计算文本宽度:

    func boundingRect(ofAttributes attributes: [NSAttributedString.Key: Any], size: CGSize) -> CGRect {
        let boundingBox = base.boundingRect(
            with: size,
            options: [.usesLineFragmentOrigin, .usesFontLeading],
            attributes: attributes,
            context: nil
        )
        return boundingBox
    }

这个函数是一个耗时函数,不适合放在主线程

SilenceLove added a commit that referenced this issue Jan 10, 2024
@SilenceLove
Copy link
Owner

已修改,不会频繁计算了。只会在需要更新的时候调计算

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants