每当我使用以下代码在运行时切换语言时:
//set apple language to force localization use the intended language
let userdef = UserDefaults.standard
userdef.set(["ar" /*or "en" to switch to english*/], forKey: "AppleLanguages")
userdef.synchronize()
//force all views to use propery layout direction
UIView.appearance().semanticContentAttribute = forceRightToLeft /*or .forceLeftToRight*/
//reload root view controller
(UIApplication.shared.delegate as? AppDelegate)?.window?.rootViewController = UIStoryboard(name: "Main", bundle: .main).instantiateInitialViewController()
任何使用组合布局的集合视图都会被镜像,而不是布局翻转而是内容被镜像。