问题
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