直播软件开发,渐变色任务进度条
直播软件开发,渐变色任务进度条实现的相关代码
[_slider setMinimumTrackImage:getGradientImageWith(@[LightBlue3,BLUECOLOR], CGRectMake(0, 0, ScreenWidth - 75 * rectScale(), 10 * rectScale()), CGPointMake(0, 0.5), CGPointMake(1, 0.5)) forState:UIControlStateNormal];
UIImage* getGradientImageWith(NSArray *colors,CGRect rect,CGPoint start,CGPoint end){
if (!colors.count || CGRectEqualToRect(rect, CGRectZero)) {
return nil;
}
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = rect;
gradientLayer.startPoint = start;
gradientLayer.endPoint = end;
NSMutableArray *mutColors = [NSMutableArray arrayWithCapacity:colors.count];
for (UIColor *color in colors) {
[mutColors addObject:(__bridge id)color.CGColor];
}
gradientLayer.colors = [NSArray arrayWithArray:mutColors];
UIGraphicsBeginImageContextWithOptions(gradientLayer.frame.size, gradientLayer.opaque, 0);
[gradientLayer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return outputImage;
}
以上就是 直播软件开发,渐变色任务进度条实现的相关代码,更多内容欢迎关注之后的文章