zoukankan      html  css  js  c++  java
  • ios小技巧,实现UITableViewCell圆角

    有时候我们需要把TableViewCell做成圆角,并且cell之间有一定间距,网上很多都是在tableView的contentView添加自己的View来实现,其实都不是特别好。那么现在有个小技巧,就是重新布局tableView的contentView。其代码如下:

    - (void)awakeFromNib {
        
        [self setuplayout];
    }
    
    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            
            [self setuplayout];
        }
        return self;
    }
    
    - (void)setuplayout {
        
        self.contentView.layer.borderColor = [[UIColor colorWithRed:234/255.0 green:234/255.0 blue:234/255.0 alpha:1.0] CGColor];
        self.contentView.layer.borderWidth = 1.0f;
        self.contentView.layer.cornerRadius = 5.0f;
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
    
    - (void)layoutSubviews {
        [super layoutSubviews];
        
        self.contentView.frame = CGRectInset(self.bounds, 5, 5);
        //由于改了contentView.frame。所以这句话要在这里执行
        self.contentView.clipsToBounds = YES;
    }

     
  • 相关阅读:
    Eureka 服务的注册和发现
    springcloud 中文文档
    mysql 7 种 join
    通用 mapper
    docker 容器操作( 以 tomcat 为例 )
    linux下安装phpunit简单方法
    图片优化的几个小工具
    安装基准测试工具sysbench
    安装pcntl以实现php多进程
    安装memcache及php的memcached模块
  • 原文地址:https://www.cnblogs.com/visonhome/p/4482754.html
Copyright © 2011-2022 走看看