自动调整后是否可以获得最终字体大小?(属性adjustsFontSizeToFitWidth设置为YES,文本字体大小正在缩小以适合标签)
我在UILabel中继承了drawTextInRect以在文本上放置渐变,但是渐变大小需要与字体的大小相同.我无法获得适当大小的调整字体......它甚至可能吗?
//draw gradient
CGContextSaveGState(myContext);
CGGradientRef glossGradient;
CGColorSpaceRef rgbColorspace;
size_t num_locations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat components[8] = { 1, 1, 1, 0.25, // BOTTOM color
1, 1, 1, 0.12 }; // UPPER color
//scale and translate so that text would not be rotated 180 deg wrong
CGContextTranslateCTM(myContext, 0, rect.size.height);
CGContextScaleCTM(myContext, 1.0, -1.0);
//create mask
CGImageRef alphaMask = CGBitmapContextCreateImage(myContext);
CGContextClipToMask(myContext, rect, alphaMask);
rgbColorspace = CGColorSpaceCreateDeviceRGB();
glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations);
//gradient should be sized …Run Code Online (Sandbox Code Playgroud) iphone ×1