UITableViewCell: rounded corners and shadow

前端 未结 14 1373
故里飘歌
故里飘歌 2020-12-02 05:05

I\'m changing the width of a UITableViewCell so that the cell is smaller but the user can still scroll along the edges of the tableview.

override func layout         


        
14条回答
  •  离开以前
    2020-12-02 05:21

    I have achieved the same thing using following code.But you have place it in layoutSubviews() method of your TableViewCell subclass.

    self.contentView.backgroundColor = [UIColor whiteColor];
    self.contentView.layer.cornerRadius = 5;
    self.contentView.layer.shadowOffset = CGSizeMake(1, 0);
    self.contentView.layer.shadowColor = [[UIColor blackColor] CGColor];
    self.contentView.layer.shadowRadius = 5;
    self.contentView.layer.shadowOpacity = .25;
    CGRect shadowFrame = self.contentView.layer.bounds;
    CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:shadowFrame].CGPath;
    self.contentView.layer.shadowPath = shadowPath;
    

提交回复
热议问题