- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGContextRef drawCtr = UIGraphicsGetCurrentContext();
CGContextSaveGState(drawCtr);
CGMutablePathRef borderPath = CGPathCreateMutable();
CGPathMoveToPoint(borderPath, NULL, 0, 0);
float fh = self.fh;
float ftop = self.ftop;
float fl = self.fleft;
float radius = self.radius;
float fw = self.fw;
CGPathMoveToPoint(borderPath, NULL, 0, 0);
CGPathAddLineToPoint(borderPath, NULL, [self width], 0);
CGPathAddLineToPoint(borderPath, NULL, [self width], ftop);
CGPathAddLineToPoint(borderPath, NULL, 0, ftop);
CGPathMoveToPoint(borderPath, NULL, 0, ftop);
CGPathAddLineToPoint(borderPath, NULL, fl + radius, ftop);
CGPathAddArcToPoint(borderPath, NULL, fl, ftop, fl, ftop + radius , radius);
CGPathAddLineToPoint(borderPath, NULL, fl, ftop + fh - radius);
CGPathAddArcToPoint(borderPath, NULL, fl , ftop + fh, fl + radius, fh + ftop, radius);
CGPathAddLineToPoint(borderPath, NULL, 0, ftop + fh);
CGPathMoveToPoint(borderPath, NULL, fw + fl - radius, ftop);
CGPathAddArcToPoint(borderPath, NULL, fw + fl, ftop , fw + fl, ftop + radius, radius);
CGPathAddLineToPoint(borderPath, NULL, fw + fl, ftop + fh - radius);
CGPathAddArcToPoint(borderPath, NULL, fw + fl, fh + ftop, fl + fw - radius, ftop + fh, radius);
CGPathAddLineToPoint(borderPath, NULL, [self width], ftop + fh);
CGPathAddLineToPoint(borderPath, NULL, [self width], ftop);
CGPathMoveToPoint(borderPath, NULL, 0, ftop + fh);
CGPathAddLineToPoint(borderPath, NULL, [self width], ftop + fh);
CGPathAddLineToPoint(borderPath, NULL, [self width], [self height]);
CGPathAddLineToPoint(borderPath, NULL, 0, [self height]);
CGContextAddPath(drawCtr, borderPath);
[[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7] setFill];
CGContextDrawPath(drawCtr, kCGPathFill);
CGPathRelease(borderPath);
CGContextRestoreGState(drawCtr);
}
划线
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 添加中划线: UILabel* strikeLabel = [[UILabelalloc] initWithFra...
- 个人博客: LiCheng的博客 引言: 当我们在做一些购物类APP或者是商品展示类的APP时,我们经常会遇到某种...
- 1. 2. iOS10.3更新后,商城APP这样的UI:原价 “¥500 ” 类似Label设置的中划线突然失效了...