2012-01-02 108 views
3

我意識到,如果我使用此代碼圓只有前2邊我UITableViewUITableView在滾動時切斷?

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; 

我的tableview內容將得到切斷,如果我向下滾動到任何東西,是UITableView的框架之下我在Interface Builder中做的。雖然如果我把這個代碼拿出來,一切都很好。

是否有一種方式來獲得兩全其美,我可以圓的上角和原始幀以下內容不會被切斷的?

謝謝!

回答

4

這是解決方案。將你的表格視圖包含在一個外部UIView中(與表格視圖的大小完全一樣,並且在封閉視圖中的表格視圖在0,0處)。然後將一個插座連接到該封閉視圖並在其上設置圓角頂部角落。

我認爲這是蘋果方面的一個錯誤。