2
그라디언트 채우기로 텍스트를 채우려고합니다. 텍스트 채우기 모드를 자르기로 설정 한 다음 그래디언트 채우기를 페인트합니다. 문제는 클립 할 텍스트 그리기 모드를 설정할 때마다 텍스트 문자열의 모든 문자가 시퀀스로 그려지기보다는 서로 위에 놓여 있다는 것입니다. 가장 기괴합니다! withFont :NSString drawInRect가 모든 문자를 겹칩니다.
CGRect r = CGRectInset(self.frame, 55, 8);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGFloat components[8] = {44/255, 54/255, 66/255, 1.0
,75/255, 92/255, 111/255, 1.0};
CGFloat locations[2] = {0, 1};
// draw the text's gradient fill
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, 2);
CGContextSetTextDrawingMode(context, kCGTextClip);
[monthString drawInRect:r withFont:f lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
CGContextFillRect(context, CGRectMake(0, 0, 320, 20));