iOS7 相关资料整理

一、更改self.title中字体颜色及大小

解释:self.title为显示navigationController中间的标题文字.iOS5默认为白色,iOS7以后,默认为黑色。且没有直接修改的api

思路:获得当前navigationItem.titleView,强制转换为UILabel,然后做相应的颜色。


二、更改self.title中字体颜色及大小

原文链接:http://www.raywenderlich.com/49316/how-to-update-your-app-for-ios-7

from:http://www.raywenderlich.com

这是一个非常好的学习、更新、了解iOS的网站,希望对大家在iOS开发过程中有所帮助!


三、iOS7 UIStatusBar 字体颜色设置

iOS7后,字体颜色默认只有白黑两种,可以自定义window的方式,不过比较麻烦,先不介绍。

此处以设置为白颜色为例。

a、直接在xxx-info.plist来设置

  • info.plist中添加View controller-based status bar appearance,设置为NO
  • info.plist中添加Status bar style,设置为Transparent black style (alpha of 0.5)

b、xxx-info.plist结合代码

  • info.plist中添加View controller-based status bar appearance,设置为NO
  • 在.m文件中加[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  • 或者在.m文件中加以下代码

     

    //- (BOOL)prefersStatusBarHidden {

    //    return NO;

    //}

    //

    //- (UIStatusBarStyle)preferredStatusBarStyle {

    //    return UIStatusBarStyleLightContent;

    //}



四、 iOS7 tintColor for navigationBar

   // for iOS7.0+

    float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];

    if (systemVersion >= 7.0)

    {

        [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

    }



五、 iOS6.0后,类似xxxFunction is deprecated编译警告warning处理。

最近在把一个iOS5.0的老项目升级到iOS7.1,发现在iOS6.0的时候,就有一些函数和枚举值被废弃。

那么在做版本兼容的时候,我们可以使用respondsToSelector这个函数,具体怎么使用就不多说了。

iOS6.0以下版本的函数、枚举(红色表示iOS6.0以上可用)

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0);

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion NS_AVAILABLE_IOS(5_0);

 

- (void)dismissModalViewControllerAnimated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0);

- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion NS_AVAILABLE_IOS(5_0);

 

 

typedef NS_ENUM(NSInteger, UILineBreakMode) {

    UILineBreakModeWordWrap = 0,            // Wrap at word boundaries

    UILineBreakModeCharacterWrap,           // Wrap at character boundaries

    UILineBreakModeClip,                    // Simply clip when it hits the end of the rect

    UILineBreakModeHeadTruncation,          // Truncate at head of line: "…wxyz". Will truncate multiline text on first line

    UILineBreakModeTailTruncation,          // Truncate at tail of line: "abcd…". Will truncate multiline text on last line

    UILineBreakModeMiddleTruncation,        // Truncate middle of line:  "ab…yz". Will truncate multiline text in the middle

} NS_DEPRECATED_IOS(2_0,6_0);

 

 

typedef NS_ENUM(NSInteger, NSLineBreakMode) {        /* What to do with long lines */

    NSLineBreakByWordWrapping = 0,         /* Wrap at word boundaries, default */

    NSLineBreakByCharWrapping,        /* Wrap at character boundaries */

    NSLineBreakByClipping,        /* Simply clip */

    NSLineBreakByTruncatingHead,    /* Truncate at head of line: "…wxyz" */

    NSLineBreakByTruncatingTail,    /* Truncate at tail of line: "abcd…" */

    NSLineBreakByTruncatingMiddle    /* Truncate middle of line:  "ab…yz" */

} NS_ENUM_AVAILABLE_IOS(6_0);

 

// Deprecated: use NSTextAlignment enum in UIKit/NSText.h

typedef NS_ENUM(NSInteger, UITextAlignment) {

    UITextAlignmentLeft = 0,

    UITextAlignmentCenter,

    UITextAlignmentRight,                   // could add justified in future

} NS_DEPRECATED_IOS(2_0,6_0);

 

/* Values for NSTextAlignment */

typedef NS_ENUM(NSInteger, NSTextAlignment) {

    NSTextAlignmentLeft      = 0,    // Visually left aligned

#if TARGET_OS_IPHONE

    NSTextAlignmentCenter    = 1,    // Visually centered

    NSTextAlignmentRight     = 2,    // Visually right aligned

#else /* !TARGET_OS_IPHONE */

    NSTextAlignmentRight     = 1,    // Visually right aligned

    NSTextAlignmentCenter    = 2,    // Visually centered

#endif

    NSTextAlignmentJustified = 3,    // Fully-justified. The last line in a paragraph is natural-aligned.

    NSTextAlignmentNatural   = 4,    // Indicates the default alignment for script

} NS_ENUM_AVAILABLE_IOS(6_0);




你可能感兴趣的:(iOS7 相关资料整理)