I put two functions in the code but it gives me this error:
Overlapping accesses to 'frame', but modification requires exclusive access; consider copying to a local variable
how can i solve?
import UIKit
extension UITabBarController {
func hideTabBar() {
var frame = self.tabBarController?.tabBar.frame
frame?.origin.y = self.view.frame.size.height + (frame?.size.height)!
UIView.animate(withDuration: 0.5, animations: {
self.tabBarController?.tabBar.frame = frame!
})
}
func showTabBar() {
var frame = self.tabBarController?.tabBar.frame
frame?.origin.y = self.view.frame.size.height - (frame?.size.height)!
UIView.animate(withDuration: 0.5, animations: {
self.tabBarController?.tabBar.frame = frame!
})
}
}
var frame: CGRect?, outside the function.func hideTabBar() { guard var frame = self.tabBarController?.tabBar.frame else { return } let originY = self.view.frame.size.height + t.size.height frame.origin.y = originY UIView.animate(withDuration: 0.5) { self.tabBarController?.tabBar.frame = frame } }t.size.heighttoframe.size.height