直播軟體開發,漸變色任務進度條
阿新 • • 發佈:2021-10-11
直播軟體開發,漸變色任務進度條實現的相關程式碼
[_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;
}
以上就是 直播軟體開發,漸變色任務進度條實現的相關程式碼,更多內容歡迎關注之後的文章