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;
    }

     
  • 相关阅读:
    vue cli 3.0安装、项目创建
    Vue-详解设置路由导航的两种方法
    VUE项目启动流程
    vue项目创建
    前端UI优秀框架
    Spring MVC返回JSON的几种方法
    Cookie 和 Session 的区别
    Object.defineProperty()
    vuex getter传入参数
    后台管理系统权限控制的思路
  • 原文地址:https://www.cnblogs.com/visonhome/p/4482754.html
Copyright © 2011-2022 走看看