//运行时检查 OS 版本if (@available(iOS 12, macOS 12, *)) { //iOS 12、macOS 12 或更高版本} else { //iOS 11、macOS 11 或更低版本}