UILabel文字豎排

方法一:spa

        UILabel *mindName = [[UILabel alloc]initWithFrame:kCR(0, 0, 25,40)];
        
        mindName.text = @"蘇\n小\n明";
        mindName.numberOfLines = [mindName.text length];
    

方法二:code

//        NSString *text = @"一";
//        NSString *strText = @"蘇得強";
//        UIFont *font = [UIFont systemFontOfSize:12];
//        CGSize sizeWord = [text sizeWithFont:font constrainedToSize:CGSizeMake(320, 2000.0) lineBreakMode:UILineBreakModeWordWrap];
//        CGFloat w = sizeWord.width;//一個漢字的寬度
//        CGSize sizeStr = [strText sizeWithFont:font constrainedToSize:CGSizeMake(w, 2000.0) lineBreakMode:UILineBreakModeWordWrap];
//        CGFloat h = sizeStr.height;
//        
//        UILabel *aLabel = [[UILabel alloc]initWithFrame:kCR(0, 0, w, h)];
//        aLabel.text = strText;
//        aLabel.backgroundColor = [UIColor clearColor];
//        aLabel.textColor = [UIColor whiteColor];
//        aLabel.numberOfLines = 0;
//        [aView addSubview:aLabel];
相關文章
相關標籤/搜索