zoukankan      html  css  js  c++  java
  • CALayer实现点击屏幕放大或者缩小的一个圆

    #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

  • 相关阅读:
    HDU1171(01背包均分问题)
    HDU2159(完全背包)
    HDU1203(01背包变形)
    DAG上的DP
    ADB命令小结
    HDU3065(AC自动机入门题)
    HDU2896(AC自动机入门题)
    性能测试监控分析(13)-sysstat安装升级
    tomcat(9)-linux apache tomcat集群环境搭建
    nginx(4)-负载均衡的5种策略及原理
  • 原文地址:https://www.cnblogs.com/thbbsky/p/4332332.html
Copyright © 2011-2022 走看看