zoukankan      html  css  js  c++  java
  • 加阴影的方法

    一、给图片加上阴影 
    
     UIImageView*pageContenterImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"onePageApple.png"]];
    
            
    
             //添加边框
    
            
    
             CALayer*layer = [pageContenterImageView layer];
    
            
    
            layer.borderColor= [[UIColor whiteColor]CGColor];
    
            
    
            layer.borderWidth=0.0f;
    
            
    
            //添加四个边阴影
    
            
    
            pageContenterImageView.layer.shadowColor= [UIColor blackColor].CGColor;
    
            
    
            pageContenterImageView.layer.shadowOffset=CGSizeMake(0,0);
    
            
    
            pageContenterImageView.layer.shadowOpacity=0.5; 
    
            
    
            pageContenterImageView.layer.shadowRadius=5.0;
    
            
    
            //添加两个边阴影
    
            
    
            //pageContenterImageView.layer.shadowColor = [UIColor blackColor].CGColor;
    
            
    
            //    pageContenterImageView.layer.shadowOffset = CGSizeMake(2, 2);
    
            
    
            //    pageContenterImageView.layer.shadowOpacity = 0.5; 
    
            
    
            //    pageContenterImageView.layer.shadowRadius = 2.0;
    
            
    
            //-------------
    
            
    
            阴影渲染会严重消耗内存 ,导致程序咔叽.
    
            
    
             /*阴影效果*/
    
            
    
             //添加边框
    
            
    
            CALayer*layer = [self.pageContenter layer];
    
            
    
            layer.borderColor= [[UIColorwhiteColor]CGColor];
    
            
    
            layer.borderWidth=0.0f;
    
            
    
            //添加四个边阴影
    
            
    
             self.pageContenter.layer.shadowColor= [UIColorblackColor].CGColor;//阴影颜色
    
            
    
             self.pageContenter.layer.shadowOffset=CGSizeMake(0,0);//阴影偏移
    
            
    
             self.pageContenter.layer.shadowOpacity=0.5;//阴影不透明度
    
            
    
             self.pageContenter.layer.shadowRadius=5.0;//阴影半径
    
            
    
            //添加两个边阴影
    
            
    
            //self.pageContenter.layer.shadowColor = [UIColor blackColor].CGColor;
    
            
    
            //self.pageContenter.layer.shadowOffset = CGSizeMake(2, 2);
    
            
    
            //self.pageContenter.layer.shadowOpacity = 0.5; 
    
            
    
            //self.pageContenter.layer.shadowRadius = 2.0; 
    
    
    
    二、给视图加上阴影
    
    
     UIView * content=[[UIView alloc] initWithFrame:CGRectMake(100, 250, 503,  500)]; 
    
        content.backgroundColor=[UIColor orangeColor];
    
        //content.layer.shadowOffset=10;
    
        
    
        
    
        content.layer.shadowOffset = CGSizeMake(5, 3);
    
        content.layer.shadowOpacity = 0.6;
    
        content.layer.shadowColor = [UIColor blackColor].CGColor;
    
        
    
        
    
        [self.window addSubview:content];
  • 相关阅读:
    Keepalived详解(一):Keepalived介绍【转】
    Python运维开发基础06-语法基础【转】
    Python运维开发基础05-语法基础【转】
    Python运维开发基础04-语法基础【转】
    Python运维开发基础03-语法基础 【转】
    Python运维开发基础02-语法基础【转】
    Python运维开发基础01-语法基础【转】
    Shell编程中while与for的区别及用法详解【转】
    rsync+inotify实现实时同步案例【转】
    Linux查看压缩文件内容【转】
  • 原文地址:https://www.cnblogs.com/gaoxiao228/p/2497666.html
Copyright © 2011-2022 走看看