美文网首页
UILabel文字的竖向排列

UILabel文字的竖向排列

作者: 旭日飞扬 | 来源:发表于2018-07-23 11:26 被阅读72次
  • (void)setLabel{
    NSString *title = @"请竖向排列!!";
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, 200)];
    lable.center = self.view.center;
    lable.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:lable];
    NSString *titleStr = @"";
    for (int i=0; i<[title length]; i++)
    {
    NSString *str = [title substringWithRange:NSMakeRange(i, 1)];

      titleStr = [NSString stringWithFormat:@"%@\n%@",titleStr,str];
    

    }
    lable.text = titleStr;
    lable.numberOfLines = [lable.text length];
    }

相关文章

网友评论

      本文标题:UILabel文字的竖向排列

      本文链接:https://www.haomeiwen.com/subject/zhwdmftx.html