0
如果我評論了shapeShadow代碼,它會顯示第二個圓圈。 -(void)shapeShadow:(UIBezierPath *)shape
發生了什麼?爲什麼這第二圈沒有顯示?
- (void)shapeShadow:(UIBezierPath *)shape此代碼是在圓圈中添加一行。
#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