2013-07-03 105 views
0

我在UItableView中添加了圓角,但只在頂角。 問題是,當我在UItableView中使用掩碼時,UItableView只顯示前4個單元格。UITableView中的頂部圓角

當我從評論面具的代碼中,實現代碼如下工作正常..

這裏是我的代碼:

UIBezierPath *maskPath; 
maskPath = [UIBezierPath bezierPathWithRoundedRect:_tbFeeds.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(9.0, 9.0)]; 

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 
maskLayer.frame = _tbFeeds.bounds; 
maskLayer.path = maskPath.CGPath; 
_tbFeeds.layer.mask = maskLayer; //tbfeeds is my tableview 
[maskLayer release]; 
+0

看起來像來自同一張海報的[這個問題]的幾乎完全重複(http://stackoverflow.com/questions/17451438/uitableview-doesnt-work-fine-when-i-use-mask)。 –

回答

0

辦法做到這將是一個頭添加到實現代碼如下:

- (void)loadView { 
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 10)]; // height of header (10) 
    [headerView setBackgroundColor:[UIColor whiteColor]]; // color of header (white) 

    UIBezierPath *maskPath; 
    maskPath = [UIBezierPath bezierPathWithRoundedRect:headerView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(5.0, 5.0)]; 

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 
    maskLayer.frame = headerView.bounds; 
    maskLayer.path = maskPath.CGPath; 
    headerView.layer.mask = maskLayer; 

    self.tableView.tableHeaderView = headerView; 
} 
-2

請參考以下鏈接查詢:

https://gist.github.com/robin/62684