标签:
代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self vertiCal];
}
#pragma -mark -functions
-(void)vertiCal
{
//将文字变为竖排
NSString *str = @"你好啊";
NSMutableArray *arr = [[NSMutableArray alloc] init];
for (int i = 0; i<str.length ; i++) {
NSString *str1 = [str substringWithRange:NSMakeRange(i, 1)];
NSString *str2 = [str1 stringByAppendingString:@"\n"];
[arr addObject:str2];
}
NSString *str3;
for (int i = 0; i<arr.count - 1; i++) {
if (i == 0) {
str3 = [arr[i] stringByAppendingString:arr[i+1]];
}else{
str3 = [str3 stringByAppendingString:arr[i+1]];
}
}
NSLog(@"%@",str3);
//初始化label
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 300)];
label.backgroundColor=[UIColor orangeColor];
label.text=str3;
label.numberOfLines=0;
[self.view addSubview:label];
}
标签:
原文地址:http://www.cnblogs.com/yang-guang-girl/p/4607278.html