码迷,mamicode.com
首页 > 其他好文 > 详细

横排文字竖排显示

时间:2015-06-29 14:42:25      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:

代码:

- (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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!