xcode UITextAttributeTextShadowOffset 已弃用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19042724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:56:30 来源:igfitidea点击:
UITextAttributeTextShadowOffset is Deprecated
提问by Benjamin Porter
I am trying to addapt my code to iOS 7.
我正在尝试将我的代码添加到 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
.
我收到了一些错误UITextAttributeColor is deprecated
、UITextAttributeTextShadowColor is deprecated
、 和UITextAttributeTextShadowOffset is deprecated
。
回答by Leo Natan
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]
}];
回答by Ritu
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];
回答by Kirit Vaghela
UIColor *blue = [UIColor colorWithRed:64.0/255.0
green:119.0/255.0
blue:255.0/255.0
alpha:1.0];
NSShadow *shadow = [NSShadow.alloc init];
shadow.shadowColor = [UIColor clearColor];
NSDictionary *attributes = @{
NSForegroundColorAttributeName: blue,
NSShadowAttributeName: shadow
};
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes
forState:UIControlStateNormal];