xcode 我想像这样将 UILabel 文本“sunday”显示为大写的“SUN”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12387452/
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 01:28:02  来源:igfitidea点击:

I want to show the UILabel text "sunday" to uppercase "SUN" like that

iphoneobjective-cxcodeuilabel

提问by Joker

NSString *strDay = [dic objectForKey:@"day"]; 
NSString *uppercaseString = [strDay uppercaseString];
cell.dayLabel.text = uppercaseString;

Is that the correct method to get that? But I get only uppercase. I want "sunday" to be shown in view like "SUN".

这是获得它的正确方法吗?但我只得到大写。我希望“星期日”像“SUN”一样显示在视图中。

回答by Sohaib

How about just this

就这个怎么样

NSString *uppercaseString = [strDay uppercaseString];
cell.dayLabel.text = [uppercaseString substringToIndex:3];

Assuming it has a valid day

假设它有一个有效的日子

回答by iSanjay

NSString *strDay = [dic objectForKey:@"day"]; 
NSString* split = [strDay substringToIndex:3];
split=[split uppercaseString];

NSLOG (@"%@",split);

NSLOG (@"%@",split);

Cheers!

干杯!

回答by TheTiger

NSString *strDay = @"sunday";
NSString *newStr = [strDay substringToIndex:3];
NSString *uppercaseString = [newStr uppercaseString];

回答by Rajneesh071

NSString *strDay = [dic objectForKey:@"day"]; 
cell.dayLabel.text = [strDay.uppercaseString substringToIndex:3]