大佬教程收集整理的这篇文章主要介绍了ios – UIView drawRect:绘制倒像素,制作一个洞,一个窗口,负空间,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要使用反向剪辑方法吗?或者我需要使用bezier路径?借口如果这是非常基本的,虽然找不到信息.
谢谢阅读!
- (void)drawRect:(CGRect)rect { // get the context CGContextRef context = UIGraphicsGetCurrentContext CGContextSaveGState(context); //draw the rounded rectangle CGContextSetstrokeColorWithColor(context,[[UIColor blackColor] CGColor]); CGContextSetRGBFillColor(context,0.8,1.0); CGContextSetLineWidth(context,_lineWidth); CGRect rrect = CGRectMake(CGRectGetMinX(rect),CGRectGetMinY(rect),CGRectGetWidth(rect),CGRectGetHeight(rect)); CGFloat radius = _cornerRadius; CGFloat minx = CGRectGetMinX(rrect),midx = CGRectGetMidX(rrect),maxx = CGRectGetMaxX(rrect); CGFloat miny = CGRectGetMinY(rrect),midy = CGRectGetMidY(rrect),maxy = CGRectGetMaxY(rrect); CGContextMoveToPoint(context,minx,midy); // Add an arc through 2 to 3 CGContextAddArcToPoint(context,miny,midx,radius); // Add an arc through 4 to 5 CGContextAddArcToPoint(context,maxx,midy,radius); // Add an arc through 6 to 7 CGContextAddArcToPoint(context,maxy,radius); // Add an arc through 8 to 9 CGContextAddArcToPoint(context,radius); // Close the path CGContextClosePath(context); // Fill the path CGContextDrawPath(context,kCGPathFill); CGContextRestoreGState(context); }
// Outer subpath: the whole rect CGContextAddRect(context,rrect); // Inner subpath: the area inside the whole rect CGContextMoveToPoint(context,midy); ... // Close the inner subpath CGContextClosePath(context); // Fill the path CGContextDrawPath(context,kCGPathEOFill);
以上是大佬教程为你收集整理的ios – UIView drawRect:绘制倒像素,制作一个洞,一个窗口,负空间全部内容,希望文章能够帮你解决ios – UIView drawRect:绘制倒像素,制作一个洞,一个窗口,负空间所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。