zoukankan      html  css  js  c++  java
  • 设置UICollectionViewCell圆角和阴影

      设置cell圆角:

        cell.contentView.layer.cornerRadius =2.0f;

        cell.contentView.layer.borderWidth =1.0f;

        cell.contentView.layer.borderColor = [UIColor clearColor].CGColor;

        cell.contentView.layer.masksToBounds =YES;


    经测试,这方法无效,具体原因,后期补上。 
     
    关键代码: cell.layer.cornerRadius = 2.0f; 
     
    写上这句就可以完美展现圆角效果,不过考虑到性能优化和离屏渲染问题,建议让UI设计师直接给圆角背景图是优选 (#^.^#) 
     

      设置cell阴影:

      cell.layer.shadowColor = [UIColor lightGrayColor].CGColor;

        cell.layer.shadowOffset = CGSizeMake(0,2.0f);

        cell.layer.shadowRadius =2.0f;

        cell.layer.shadowOpacity =1.0f;

        cell.layer.masksToBounds =NO;

        cell.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:cell.bounds cornerRadius:cell.contentView.layer.cornerRadius].CGPath;


    (目前测试阴影还未测试,暂时写上此方法,有什么见解的童鞋欢迎留言指点江山)
     
     
     
  • 相关阅读:
    三维形体的表面积
    访问所有点的最小时间
    链式队列
    顺序队列
    链栈
    顺序栈
    双向链表
    pyrhon 开始 基础类型
    GDI+_VB6_ARGB
    WindowsPhone自定义控件详解(一)
  • 原文地址:https://www.cnblogs.com/liuzhi20101016/p/11908071.html
Copyright © 2011-2022 走看看