Closed hccgk closed 7 years ago
- (void)drawText:(CGContextRef)context withRect:(CGRect)rect
{
if (_indicatorTextLabel == nil)
{
return;
}
CGRect innerRect = CGRectInset(rect, 4, 2);
_indicatorTextLabel.frame = innerRect;
NSString *indicatorText = _indicatorTextLabel.text;
BOOL hasText = (_indicatorTextLabel.text != nil);
if (!hasText)
{
indicatorText = [NSString stringWithFormat:@"%.0f%%", (self.progress * 100)];
}
CGRect textRect;
if ([indicatorText respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)])
{
textRect = [indicatorText boundingRectWithSize:CGRectInset(innerRect, 20, 0).size
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{ NSFontAttributeName: _indicatorTextLabel.font }
context:nil];
}
**if (innerRect.size.width < textRect.size.width || innerRect.size.height + 4 < textRect.size.height)**
{
return;
}
Thank you for the hint! And sorry for the late.
use xcode analyze will show this problem