我想获得进度条,如下图所示:
Striped loading progress bar with triangle at the end
在github https://github.com/iluuu1994/ITProgressBar-iOS项目的帮助下,到目前为止我已经完成了这项工作,所以这就是我的尝试:
UIGraphicsBeginImageContextWithOptions(CGSizeMake(42, self.frame.size.height-10), NO, 0.f);
UIColor* color = [UIColor colorWithRed:251.0f/255.0f green:235.0f/255.0f blue:77.0f/255.0f alpha:1.0f];
UIBezierPath *bezierPath = [UIBezierPath new];
[bezierPath moveToPoint:CGPointMake(0.0, 0.0)];
[bezierPath addLineToPoint:CGPointMake(23, 0)];
[bezierPath addLineToPoint:CGPointMake(42, 29)];
[bezierPath addLineToPoint:CGPointMake(23, 70)];
[bezierPath addLineToPoint:CGPointMake(0, 70)];
[bezierPath addLineToPoint:CGPointMake(20, 29)];
[bezierPath addLineToPoint:CGPointMake(0, 0)];
[bezierPath closePath];
[color setFill];
[bezierPath fill];
}];
}
我试图从UIView覆盖drawRect方法,但似乎没有任何效果,所以我努力将掩码应用到我正在使用的图层。