Check iOS version at runtime?

前端 未结 11 1200
-上瘾入骨i
-上瘾入骨i 2020-12-01 03:03

This is sort of a follow on from my last question. I am using beginAnimations:context: to setup an animation block to animate some UITextLabels. However I notic

11条回答
  •  遥遥无期
    2020-12-01 03:16

    A bit nicer and more efficient adaptation to the above solutions:

    -(CGPoint)getOsVersion
    {
        static CGPoint rc = {-1,-1};
        if (rc.x == -1) {
            NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
            rc.x = [versionCompatibility[0] intValue];
            rc.y = [versionCompatibility[1] intValue];
        }
        return rc;
    }
    

    now you can

    if ([self getOsVersion].x < 7) {
    }
    

    HTH

提交回复
热议问题