To enable ProMotion and variable refresh rate in your Swift application, you need to set your display's preferred frame rate and configure the view that you want to use with a variable refresh rate. ProMotion allows for smoother animations and more responsive interactions by dynamically adjusting the refresh rate based on the content being displayed.
Here’s a basic example of how to opt into ProMotion in a UIViewController:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if #available(iOS 15.0, *) {
let displayLink = CADisplayLink(target: self, selector: #selector(update))
displayLink.preferredFramesPerSecond = 120 // Set the preferred frame rate to 120Hz
displayLink.add(to: .current, forMode: .default)
}
}
@objc func update() {
// Update your UI here
}
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?