iOS: Determine if device language is Right to Left (RTL)

前端 未结 11 1861
后悔当初
后悔当初 2020-12-04 23:20

Is there a way to easily determine if the language the device is set to is right to left (RTL)?

11条回答
  •  猫巷女王i
    2020-12-05 00:19

    Thanks to Kevin Ballard's answer I was able to create the following utility function to do this:

    + (BOOL)isDeviceLanguageRTL {
       return [NSLocale characterDirectionForLanguage:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]==NSLocaleLanguageDirectionRightToLeft;
    }
    

提交回复
热议问题