繁体   English   中英

如何在iOS应用中添加斜角文字效果?

[英]How do I add beveled text effect in an iOS app?

是否可以在应用程序中显示的图像中添加斜角文字效果? 我可以使用图像显示斜角文本,但现在我需要以编程方式进行此操作。

斜面S

您可以借助

   +(UIImage*) drawText:(NSString*) text
        inImage:(UIImage*)  image
        atPoint:(CGPoint)   point
   {

       UIFont *font = [UIFont boldSystemFontOfSize:12];
       UIGraphicsBeginImageContext(image.size);
       [image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
       CGRect rect = CGRectMake(point.x, point.y, image.size.width, image.size.height);
       [[UIColor whiteColor] set];
       [text drawInRect:CGRectIntegral(rect) withFont:font];
       UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
       UIGraphicsEndImageContext();

       return newImage;
    }

但请确保您正确添加阴影。 如果需要,添加多个带有不同阴影的文本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM