hanjian

在iOS开发中,经常要考虑系统的向下兼容,如果使用了低版本不存在的API ,则不能向下兼容,这时候如果想兼容低版本,就需要根据当前设备的版本进行不同的处理,在低版本中可能要牺牲一些新功能。

下面以UITabBarItem修改字体为例,说明一下如何向下兼容

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {

    // iOS 5 code

    for(UITabBarItem *tabBarItem in self.tabBar.items)

        

    {

        [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:

                                            [UIFont systemFontOfSize:14.0], UITextAttributeFont, nil]

                                  forState:UIControlStateNormal];

    }

}

else {

    // iOS 4.x code

}

 

 

 转载:http://www.giser.net/?p=955

 

分类:

技术点:

相关文章:

  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2021-12-13
  • 2022-02-10
  • 2021-12-13
  • 2021-12-03
  • 2022-01-04
  • 2021-06-29
  • 2021-11-14
相关资源
相似解决方案