CALayer实现点击屏幕放大或者缩小的一个圆
2015-03-12 14:29
489 查看
#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:0 green:146/255.0 blue:1.0 alpha:1.0].CGColor; layer.position=CGPointMake(size.width/2, size.height/2); layer.bounds=CGRectMake(0, 0, WIDTH, WIDTH); layer.cornerRadius=WIDTH/2; layer.shadowColor=[UIColor grayColor].CGColor; layer.shadowOffset=CGSizeMake(2, 2); 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[0]; CGFloat width=layer.bounds.size.width; if (width==WIDTH) { width=WIDTH *4; } else { width=WIDTH; } layer.bounds=CGRectMake(0, 0, width, width); layer.position=[touch locationInView:self.view]; layer.cornerRadius=width/2; [self.view.layer addSublayer:layer]; } @end
相关文章推荐
- canvas画一个图片,并实现点击按钮上移下移左移右移放大缩小
- 属性动画图片从上移动到屏幕中间,放大图片的二倍再缩小到原来,自定义圆实现倒计时,解析数据显示,点击条目实现js交互
- 属性动画图片从上移动到屏幕中间,放大图片的二倍再缩小到原来,自定义圆实现倒计时,解析数据显示,点击条目实现js交互
- 基于jquery实现一张图片点击鼠标放大再点缩小
- unity3d实现一个放大缩小视角左右旋转视角的效果
- 实现图片放大缩小,点击热点响应事件
- WIN32汇编语言在窗口添加按钮,点击按钮实现跳转到一个程序或者一个URL。。。
- ImageView+ViewPager+PhotoView实现朋友圈图片点击全屏查看支持放大缩小
- JavaScript实现点击按钮字体放大、缩小
- gallery扩展2——animation基于java代码——实现点击放大缩小
- 【android】:android积累2之如何实现点击一个按钮或者选项然后出现一条消息
- 鼠标点击实现图片的缓慢放大和缓慢缩小
- 如何在 Unity 2D 和 3D 中放大或缩小以及点击屏幕
- 实现图片的点击放大,再点击缩小
- JavaScript实现点击按钮字体放大、缩小
- android点击实现图片放大缩小
- 基于jquery实现一张图片点击鼠标放大再点缩小
- [jQuery]地图浏览:如何实现图片的放大缩小和点击之后的位置居中
- 实现类似于QQ空间相册的点击图片放大,再点后缩小回原来位置
- 图标放大缩小移动,加标注点,并带点击效果的实现