iOS 字体竖着显示

iOS 字体竖着显示

#import 

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"你好世界 世界"];
    
    CFBooleanRef flag = kCFBooleanTrue;
    [str addAttribute:(id)kCTVerticalFormsAttributeName value:(__bridge id)flag range:NSMakeRange(0, [str length])];
    
    [str addAttribute:(id)kCTForegroundColorAttributeName value:(id)[UIColor redColor].CGColor range:NSMakeRange(0, [str length])];
    
    //下划线
    [str addAttribute:(id)kCTUnderlineStyleAttributeName value:(id)[NSNumber numberWithInt:kCTUnderlineStyleDouble] range:NSMakeRange(0, 4)];
    //下划线颜色
    [str addAttribute:(id)kCTUnderlineColorAttributeName value:(id)[UIColor redColor].CGColor range:NSMakeRange(0, 4)];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 20)];;
    label.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:label];
    
    label.attributedText = str;
    
    //label.transform = CGAffineTransformMakeRotation(M_PI_2);
    label.layer.transform = CATransform3DMakeRotation(M_PI_2, 0, 0, 1);
}

你可能感兴趣的:(iOS_UI)