2016-09-29 44 views
0

使用此代碼我得到了我的個人資料圖片在正確的D形狀但在之後當我滾動tableView不是當我們進入視圖控制器。在滾動TableView之前無法在CellForRowAtIndexPath中應用UIBezierPath

UIBezierPath *maskPath; 
maskPath = [UIBezierPath bezierPathWithRoundedRect:cellimg.boundsbyRoundingCorners:(UIRectCornerBottomRight|UIRectCornerTopRight)cornerRadii:CGSizeMake(40.0, 40.0)]; 
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 
maskLayer.frame =cellimg.bounds; 
maskLayer.path = maskPath.CGPath; 
cellimg.layer.mask = maskLayer; 
+0

'[yourTableView reloadData]'....在你的'viewDidLoad'方法中加入這一行。 –

+0

請編輯問題標題 – Aleksey

+0

嗨.. M Zubair Shamshad它不適合我。當我們滾動表格視圖時,靜態圖片仍然以d形狀顯示..個人資料圖片來自web Service。m在CellForRowAtIndex中編寫此代碼..任何其他的sol請務必... thanku – user6898211

回答

0

與下面的代碼使用d形狀的掩模圖像也可能是爲你工作

的CALayer *掩模= [CALayer的層]

mask.contents =(ID)[UIImage的imageNamed:@「your_D_ShapeMask.png「] CGImage;

mask.frame = CGRectMake(0,0,100,100);

[cellimg。 .layer setMask:mask];

相關問題