|
CGAffineTransform matrix = CGAffineTransformMake(1, 0, tanf(15 * (CGFloat)M_PI / 180), 1, 0, 0); UIFontDescriptor *desc = [ UIFontDescriptor fontDescriptorWithName :[ UIFont systemFontOfSize :17 ]. fontName matrix :matrix]; font = [ UIFont fontWithDescriptor :desc size :17]; ios中不支持中文傾斜,于是只有設(shè)置傾斜角度。 第一行代碼:設(shè)置反射。傾斜15度。 第二行代碼:取得系統(tǒng)字符并設(shè)置反射。 第三行代碼:獲取字體。 上面的代碼,通過舍子font的f可以實(shí)現(xiàn),可以實(shí)現(xiàn)中文斜體。后面可以用 [string. text drawInRect :dr withFont :font lineBreakMode : NSLineBreakByTruncatingTail ]; 繪制出斜體字。
效果如圖: |
|
|