iOS drawInRect 内容居中显示方法

621 阅读1分钟

NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; style.alignment = NSTextAlignmentCenter; NSDictionary *attr = [NSDictionary dictionaryWithObject:style forKey:NSParagraphStyleAttributeName]; [@"1" drawInRect:frame withAttributes:attr];