简体   繁体   中英

UITableView cut off when scrolling?

I just realized that if I use this code to round only the top 2 edges of my UITableView :

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:thetableView.bounds 
                                                   byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                                         cornerRadii:CGSizeMake(10.0, 10.0)];
    // Create the shape layer and set its path
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = thetableView.bounds;
    maskLayer.path = maskPath.CGPath;
    thetableView.layer.mask = maskLayer;

My tableview content will get cut off if I scroll down to anything that was below the frame of the UITableView that I made in Interface Builder. Although if I take this code out, everything is fine.

Is there a way to get the best of both worlds where I can round the top corners and the content below the original frame doesn't get cut off?

Thanks!

Here is the solution. Enclose your table view in an outer UIView (exactly the same size as the table view, and with the table view at 0,0 in the enclosing view). Then hook up an outlet to that enclosing view and set rounded top corners on it.

I think this is a bug on Apple's part.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM