我想展示UILabel文字" sunday"大写" SUN"像那样

时间:2012-09-12 11:45:45

标签: iphone objective-c xcode uilabel

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

这是正确的方法吗?但我只得到大写。我希望“sunday”能像“SUN”一样显示在视野中。

4 个答案:

答案 0 :(得分:20)

这个怎么样

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

假设它有一个有效的日子

答案 1 :(得分:3)

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

NSLOG(@“%@”,拆分);

干杯!

答案 2 :(得分:0)

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

答案 3 :(得分:0)

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