Ios 为什么第二圈没有';你不来吗?
如果我对shapeShadow代码进行了注释,它将显示第二个圆圈。 在Ios 为什么第二圈没有';你不来吗?,ios,uiview,drawrect,uibezierpath,Ios,Uiview,Drawrect,Uibezierpath,如果我对shapeShadow代码进行了注释,它将显示第二个圆圈。 在-(void)shapeShadow:(UIBezierPath*)shape中发生了什么 -(void)shapeShadow:(UIBezierPath*)形状此代码是圆中的添加线 #import "SetCard.h" @implementation SetCard -(void)drawRect:(CGRect)rect { UIBezierPath *roundedRect=[UIBezierPath be
-(void)shapeShadow:(UIBezierPath*)shape中发生了什么
-(void)shapeShadow:(UIBezierPath*)形状此代码是圆中的添加线
#import "SetCard.h"
@implementation SetCard
-(void)drawRect:(CGRect)rect
{
UIBezierPath *roundedRect=[UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:10];
[roundedRect addClip];
[[UIColor whiteColor]setFill];
UIRectFill(self.bounds);
[[UIColor blackColor]setStroke];
[self drawShape];
}
-(void)drawShape
{
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
for (int i=1; i<3; i++) {
CGContextTranslateCTM(context, self.bounds.size.width*(i-1)/3, 0);
[self drawCircle];
}
CGContextRestoreGState(context);
}
-(UIBezierPath *)drawCircle
{
CGPoint center=CGPointMake(self.bounds.size.height/5, self.bounds.size.height/2);
UIBezierPath *circle=[UIBezierPath bezierPathWithArcCenter:center radius:self.bounds.size.height/5 startAngle:0 endAngle:12 clockwise:YES];
[circle closePath];
circle.lineWidth=3;
[[UIColor blueColor]setFill];
[[UIColor blackColor]setStroke];
[circle stroke]; [self shapeShadow:circle];
return circle;
}
-(void)shapeShadow:(UIBezierPath *)shape
{
// [shape addClip];
// for(int j=0;j<15;j++){
// CGFloat c=0.05*j*self.bounds.size.height;
// UIBezierPath *line=[UIBezierPath bezierPath];
// [line moveToPoint:CGPointMake(c, 0.0)];
// [line addLineToPoint:CGPointMake(c, self.bounds.size.height)];
// line.lineWidth=2;
// [line fill];[line stroke];
// }
}
@end
#导入“SetCard.h”
@实现设置卡
-(void)drawRect:(CGRect)rect
{
UIBezierPath*roundedRect=[UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:10];
[roundedRect addClip];
[[UIColor whiteColor]setFill];
UIRectFill(自边界);
[[UIColor blackColor]设定行程];
[自拉伸形状];
}
-(空)拉伸形状
{
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextSaveGState(上下文);
对于(int i=1;i,由于该方法调用[shape addClip]
,并将路径转换为剪裁规范,因此不再绘制,因此它阻止在指定区域中绘制