我有一个应用程序,每次用户绘制手绘圆圈时,程序都会分配/初始化到一个圆圈类(uiview),该类绘制 CAShapelayer 圆圈,而不是用户绘制的圆圈。现在我希望当用户按下超级视图上的按钮时,绘制的圆圈的 alpha 会改变。这是相关代码:
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];