Этот код ниже — это то, что я использую для создания своего подпредставления «theSubview», которое я добавляю в родительское представление «parentView».
Скажем, parentView имеет фрейм {{0.0, 0.0}, {100.0, 100.0}}, а theSubview имеет фрейм {{20.0, 20.0}, {20.0, 20.0}}.
Проблема в том, что когда мой рисунок готов, я получаю не только синюю стрелку, но и синий контур, который находится на рамке подпредставления.
Любые идеи, что я делаю неправильно?
Спасибо!
// theSubview
// My UIView subclass that is added to another view
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
}
return self;
}
- (void)drawRect:(CGRect)rect {
[self drawArrow];
}
- (void)drawArrow {
CGRect arrowRect;
arrowRect = self.bounds;
UIBezierPath *arrowPath = [UIBezierPath bezierPathWithRect:arrowRect];
// UIColor *backgrColor = [UIColor grayColor];
// [backgrColor setFill];
// [arrowPath fillWithBlendMode:kCGBlendModeNormal alpha:0.9f];
UIColor *strokeColor = [UIColor blueColor];
[strokeColor setStroke];
CGFloat thirdOfWidth = floorf(CGRectGetWidth(self.bounds) / 3);
CGFloat thirdOfHeight = floorf(CGRectGetHeight(self.bounds) / 3);
[arrowPath moveToPoint:CGPointMake(thirdOfWidth, thirdOfHeight)];
[arrowPath addLineToPoint:CGPointMake(thirdOfWidth * 2, thirdOfHeight + (floorf(thirdOfHeight/2)))];
[arrowPath addLineToPoint:CGPointMake(thirdOfWidth, thirdOfHeight * 2)];
[arrowPath setLineWidth:3.0f];
[arrowPath stroke];
}