ユーザーがフリーハンドの円を描くたびに、ユーザーが描いたものではなく CAShapelayer 円を描く円クラス (uiview) にプログラムが割り当て/初期化するアプリがあります。ユーザーがスーパービューのボタンを押すと、描かれた円のアルファが変化するようになりました。これは関連するコードです:
blueCircleView =[[ASFBlueCircle alloc]initWithFrame:CGRectMake(startPoint.x-10, startPoint.y-20, 60, 60)];
[self addSubview:blueCircleView];
クラスからの初期化コード:
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
    // Initialization code
    self.backgroundColor=[UIColor clearColor];
     UIBezierPath *circle = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 75, 75)];
   blueCircleLayer = [CAShapeLayer layer];
    blueCircleLayer.path = circle.CGPath;
    blueCircleLayer.strokeColor = [UIColor blueColor].CGColor;
    blueCircleLayer.fillColor = [UIColor clearColor].CGColor;
    blueCircleLayer.shadowColor =[UIColor blackColor].CGColor;
    blueCircleLayer.shadowOffset = CGSizeMake(0.0f, 5.0f);
    blueCircleLayer.shadowOpacity = 0.7f;
    blueCircleLayer.lineWidth = 7.0;
    [self.layer addSublayer:blueCircleLayer];