I want to add custom UIView
for example with 10px of height to the top of my UITableviewCell
.
My UITableview
is grouped style and the problem is that my UIView
is not rounded and UITableviewCell
does not clip this view.
Here is the code of awakeFromNib
for CustomCell
-(void) awakeFromNib
{
self.clipsToBounds=YES;
self.headerView.layer.masksToBounds=YES;
}
Here is the final result which i want to achieve
The result I'm getting
EDIT: This may be the issue since clipToBounds is not working on the backgroudView or contentView: https://stackoverflow.com/a/919408/480415
I believe that the rounded corners of the Grouped style are actually backgrounds of the table cells. Thus you can't just replace the white part, because it's not solid color with drawn border - it's ImageView acting as backgroundView for the cell (using different graphics depending of the cell row and number of rows in section).
If that is the case than you may have use Core Graphics and customize the cells to your liking. Heres a good tutorial by Ray Wenderlich
A couple things I would try:
First.. just see if this has any effect:
self.backgroundView.clipsToBounds = YES;
and
self.contentView.clipsToBounds = YES;
If not, I would try to round the headerView
self.headerView.layer.cornerRadius = 5; //try different ints here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.