Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextAttributeTextShadowOffset is Deprecated

I am trying to addapt my code to iOS 7.

 [[UIBarButtonItem appearance] setTitleTextAttributes:@{
                            UITextAttributeTextColor: [UIColor colorWithRed:214.0f/255.0f green:210.0f/255.0f blue:197.0f/255.0f alpha:1.0f],
                      UITextAttributeTextShadowColor: [UIColor colorWithWhite:0.0f alpha:0.750f],
                     UITextAttributeTextShadowOffset: [NSValue valueWithCGSize:CGSizeMake(0.0f, 1.0f)]

I am getting a few errors, UITextAttributeColor is deprecated, UITextAttributeTextShadowColor is deprecated, and UITextAttributeTextShadowOffset is deprecated.

like image 733
Benjamin Porter Avatar asked Sep 27 '13 04:09

Benjamin Porter


2 Answers

NSShadow *shadow = [NSShadow new];
[shadow setShadowColor: [UIColor colorWithWhite:0.0f alpha:0.750f]];
[shadow setShadowOffset: CGSizeMake(0.0f, 1.0f)];

[[UIBarButtonItem appearance] setTitleTextAttributes:@{
  NSForegroundColorAttributeName: [UIColor colorWithRed:214.0f/255.0f green:210.0f/255.0f blue:197.0f/255.0f alpha:1.0f],
  NSShadowAttributeName: shadow]
}];
like image 79
Léo Natan Avatar answered Oct 15 '22 00:10

Léo Natan


NSShadow *shadow = [NSShadow new];
[shadow setShadowColor : [UIColor colorWithWhite:0.0f alpha:0.750f]];
[shadow setShadowOffset : CGSizeMake(0.0f, 1.0f)];

[[UITabBarItem appearance] setTitleTextAttributes:
@{ 
    NSFontAttributeName : [UIFont fontWithName:@"AmericanTypewriter" size:10.0f],
    NSForegroundColorAttributeName : [UIColor grayColor],
    NSShadowAttributeName: shadow
}
forState:UIControlStateNormal];

[[UITabBarItem appearance] setTitleTextAttributes:
@{ 
    NSFontAttributeName : [UIFont fontWithName:@"AmericanTypewriter" size:10.0f],
    NSForegroundColorAttributeName : [UIColor blackColor],
    NSShadowAttributeName : shadow
}
forState:UIControlStateSelected];
like image 34
Ritu Avatar answered Oct 15 '22 01:10

Ritu