#import "ViewController.h"
#define WIDTH 50
@interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
[self drawMyLayer];
}
-(void)drawMyLayer
{
CGSize size=[UIScreen mainScreen].bounds.size; CALayer *layer=[[CALayer alloc]init];
layer.backgroundColor=[UIColor colorWithRed: green:/255.0 blue:1.0 alpha:1.0].CGColor;
layer.position=CGPointMake(size.width/, size.height/);
layer.bounds=CGRectMake(, , WIDTH, WIDTH);
layer.cornerRadius=WIDTH/;
layer.shadowColor=[UIColor grayColor].CGColor;
layer.shadowOffset=CGSizeMake(, );
layer.shadowOpacity=0.9;
[self.view.layer addSublayer:layer]; }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; }
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[touches anyObject];
CALayer *layer=self.view.layer.sublayers[];
CGFloat width=layer.bounds.size.width;
if (width==WIDTH) {
width=WIDTH *;
}
else
{
width=WIDTH;
}
layer.bounds=CGRectMake(, , width, width);
layer.position=[touch locationInView:self.view];
layer.cornerRadius=width/;
[self.view.layer addSublayer:layer];
}
@end