iOS 字体竖着显示

来源:互联网 发布:mysql分32位和64位吗 编辑:程序博客网 时间:2024/04/29 10:12
iOS 字体竖着显示#import <CoreText/CoreText.h>@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);}

原创粉丝点击