【发布时间】:2013-07-08 09:05:26
【问题描述】:
我有一个应用程序,每次用户绘制手绘圆圈时,程序都会分配/初始化一个圆圈类(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];
【问题讨论】:
-
那么,问题是什么?你做了什么,出了什么问题?向我们展示一些捕捉用户手势的代码,例如
标签: iphone ios uiview addsubview