/** * 在UIlabel的子类里实现 * */ - (void)drawRect:(CGRect)rect { [super drawRect:rect]; [self.textColor set]; CGFloat w = rect.size.width; CGFloat h = rect.size.height; /** * UIRectFill * Fills the specified rectangle with the current color * 用颜色填充指定的区域 */ UIRectFill(CGRectMake(0, h * 0.3, w, 1)); }