在滚动TableView之前无法在CellForRowAtIndexPath中应用UIBezierPath
问题描述:
使用此代码我得到了我的个人资料图片在正确的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;
答
与下面的代码使用d形状的掩模图像也可能是为你工作
的CALayer *掩模= [CALayer的层]
mask.contents =(ID)[UIImage的imageNamed:@“your_D_ShapeMask.png“] CGImage;
mask.frame = CGRectMake(0,0,100,100);
[cellimg。 .layer setMask:mask];
'[yourTableView reloadData]'....在你的'viewDidLoad'方法中加入这一行。 –
请编辑问题标题 – Aleksey
嗨.. M Zubair Shamshad它不适合我。当我们滚动表格视图时,静态图片仍然以d形状显示..个人资料图片来自web Service。m在CellForRowAtIndex中编写此代码..任何其他的sol请务必... thanku – user6898211