#pragma 绘制带虚线的背景
- (UIImage *)dashBg{
CGFloat bgW = self.view.bounds.size.width;
CGFloat bgH = 25;
//使用位图上下文
UIGraphicsBeginImageContext(CGSizeMake(bgW, bgH));
CGContextRef context = UIGraphicsGetCurrentContext();
//画虚线
//计算线的位置
[[UIColor redColor]set];
CGFloat lengths[2] = {5,2};
CGContextSetLineDash(context, 0, lengths, 2);
CGFloat lineH = 1;
CGPoint points[2] = {{0,bgH-lineH},{bgW,bgH-lineH}};
CGContextAddLines(context, points, 2);
CGContextStrokePath(context);
UIImage *bgImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return bgImage;
}
IOS绘制虚线
最新推荐文章于 2023-03-04 14:06:45 发布