
我需要使用反向剪辑方法吗?或者我需要使用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);}解决方法 在上下文中添加多个子路径,并使用模式kCGPathEOFill进行绘制. The Quartz 2D Programming Guide explains in more detail. // Outer subpath: the whole rectCGContextAddRect(context,rrect);// Inner subpath: the area insIDe the whole rect CGContextMovetoPoint(context,mIDy);...// Close the inner subpathCGContextClosePath(context);// Fill the pathCGContextDrawPath(context,kCGPathEOFill);总结
以上是内存溢出为你收集整理的ios – UIView drawRect:绘制倒像素,制作一个洞,一个窗口,负空间全部内容,希望文章能够帮你解决ios – UIView drawRect:绘制倒像素,制作一个洞,一个窗口,负空间所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)