[[+content_image]]
I
I
iRazGAr2014-01-07 04:59:52
iOS
iRazGAr, 2014-01-07 04:59:52

Why is it impossible to remove errors when compiling an application for iOS7?

self.navigationController = [[NavigationController alloc] initWithRootViewController:rootController];
    [[UIToolbar appearance] setBackgroundImage:[UIImage imageWithColor:[SIMenuConfiguration selectionColor]] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
    
    
    [[UINavigationBar appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor grayColor], UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
      [UIColor whiteColor], UITextAttributeTextColor,
      [UIFont fontWithName:FONT_BOLD size:17.0], UITextAttributeFont,
      nil]];

     
    [[UIBarButtonItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor grayColor], UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
      [UIColor whiteColor], UITextAttributeTextColor,
      [UIFont fontWithName:FONT_BOLD size:10.0], UITextAttributeFont,
      nil] forState:UIControlStateNormal];

These are the wonderful errors that the fifth xcode knocks out: screenshot .

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Mr_Kibernetik, 2014-01-07
@iRazGAr

Xcode reports that the keys are out of date and recommends changing them to different ones. Accordingly, the objects will also be different.
For example, the UITextAttributeTextShadowColor key suggests changing to NSShadowAttributeName. Well, accordingly, the UIColor object asks to be changed to an NSShadow object.
Instead of [UIColor grayColor], you first have to create an NSShadow and set parameters for it:
NSShadow *shadow = [NSShadow new];
[shadow setShadowColor: [UIColor grayColor]];
[shadow setShadowOffset: CGSizeMake(0, 0)];
But the second UITextAttributeTextShadowOffset key is not needed at all, because the shadow offset is already included in the NSShadow object. As a result, the first two lines will be replaced by one:
shadow, NSShadowAttributeName
The next two keys simply changed the name, but the objects remained the same. As a result, UINavigationBar will be described like this:

NSShadow *shadow = [NSShadow new];
[shadow setShadowColor: [UIColor grayColor]];
[shadow setShadowOffset: CGSizeMake(0, 0)];
[[UINavigationBar appearance] setTitleTextAttributes:
  [NSDictionary dictionaryWithObjectsAndKeys:
    shadow, NSShadowAttributeName,
    [UIColor whiteColor], NSForegroundColorAttributeName,
    [UIFont fontWithName: FONT_BOLD size: 17], NSFontAttributeName,
    nil]];

I
iRazGAr, 2014-01-07
@iRazGAr

@Mr_Kibernetik , Not fully figured out how to rewrite correctly. How should this code look like under ios7? Same mistakes.
Thanks in advance

title.tintColor = [UIColor clearColor];
    [title setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor grayColor], UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
      [UIColor whiteColor], UITextAttributeTextColor,
      [UIFont fontWithName:FONT_BOLD size:17.0], UITextAttributeFont,
      nil] forState:UIControlStateNormal];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question