How to fill Imageview letter / character in Swift?

荒凉一梦 提交于 2020-01-16 07:41:08

问题


I am a beginner in iOS. I am working on the character fill up of UIImageView. Like if image show "R" user need to draw/fill "R" Character then next character show. How can I achieve that?

Example :

Below snippet of code try from my side (in Objective - C):

CGPoint currentPoint = pointB;

if ([UIScreen.mainScreen respondsToSelector:@selector(scale)]) {
    UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, UIScreen.mainScreen.scale);
}
else {
    UIGraphicsBeginImageContext(self.frame.size);
}

[tempDrawImage.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), pointA.x, pointA.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), brush );
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeNormal);

CGContextStrokePath(UIGraphicsGetCurrentContext());
tempDrawImage.image = UIGraphicsGetImageFromCurrentImageContext();
[tempDrawImage setAlpha:opacity];
UIGraphicsEndImageContext();

UIGraphicsBeginImageContext(tempDrawImage.frame.size);
[tempDrawImage.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) blendMode:kCGBlendModeNormal alpha:opacity];
UIGraphicsEndImageContext();

Let me know how to achieve this functionality.

来源:https://stackoverflow.com/questions/48761969/how-to-fill-imageview-letter-character-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!