全局变量一个CALayer的对象
@property(nonatomic,strong)CALayer *layel;
_layel = [[CALayer alloc]init];
_layel.bounds = CGRectMake(0, 0, HEIGHT, HEIGHT);
_layel.position = CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2);
_layel.cornerRadius = HEIGHT/2;
_layel.borderWidth = 2;
_layel.backgroundColor = [UIColor redColor].CGColor;
_layel.borderColor = [UIColor grayColor].CGColor;
[self.view.layer addSublayer:_layel];
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
CGPoint point = [[touches anyObject]locationInView:self.view];
_layel.position = point;
int radius = _layel.bounds.size.width;
if (radius == HEIGHT)
{
radius = HEIGHT * 4;
}
else
{
radius = HEIGHT;
}
_layel.bounds = CGRectMake(0, 0, radius, radius);
_layel.cornerRadius = radius/2;
}