iOS 歌词颜色渲染、填充

废话不多说,直接上代码

.h文件

@interfaceoptionalView :UILabel

/**填充色,从左开始*/

@property(nonatomic,strong)UIColor*fillColor;

/**滑动进度*/

@property(nonatomic,assign)CGFloatprogress;

@end

.m文件

#import"optionalView.h"

@implementationoptionalView

//滑动进度

- (void)setProgress:(CGFloat)progress {

_progress= progress;

[selfsetNeedsDisplay];

}

- (void)drawRect:(CGRect)rect {

[superdrawRect:rect];

[_fillColorset];

CGRectnewRect = rect;

newRect.size.width= rect.size.width*self.progress;

UIRectFillUsingBlendMode(newRect,kCGBlendModeSourceIn);绘制

}

@end

你可能感兴趣的:(iOS 歌词颜色渲染、填充)