ios - UITableViewCell Auto Layout Width Not Working With UIBezierPath -
i'm having problem auto layout constraints in uitableviewcell when using uibezierpath. cell wont go full width. can see different between image 1 , image 2. image 2 didn't add rounding corners.
image 1
image 2
previously, i'm having same problem uibezierpath in uiview (you can see first 2 uiview "0"). workaround i'm using mask rounding corners in viewdidlayoutsubviews below codes:-
- (void)viewdidlayoutsubviews { [super viewdidlayoutsubviews]; [self.view layoutifneeded]; uiview *container = (uiview *)[self.view viewwithtag:100101]; [container setbackgroundcolor:[uicolor colorwithhexstring:@"ffffff"]]; [self setmaskto:container byroundingcorners:uirectcornerallcorners]; }
but i'm stuck in uitableviewcell because cant add rounding corners in viewdidlayoutsubviews. codes below:-
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"mydata"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } mywclass *w = [_wdata objectatindex:indexpath.row]; uiview *container = (uiview *) [cell viewwithtag:200001]; [container setbackgroundcolor:[uicolor colorwithhexstring:w.bgcolor]]; uibezierpath *maskpath = [uibezierpath bezierpathwithroundedrect:container.layer.bounds byroundingcorners:uirectcornertopleft | uirectcornertopright cornerradii:cgsizemake(10.0, 10.0)]; cashapelayer *masklayer = [cashapelayer layer]; masklayer.frame = container.bounds; masklayer.path = maskpath.cgpath; container.layer.mask = masklayer; [cell setbackgroundcolor:[uicolor colorwithhexstring:@"#efeff4"]]; cell.layer.maskstobounds = no; cell.layer.shadowopacity = 1.0; cell.layer.shadowoffset = cgsizemake(0, 2); cell.layer.shadowcolor = [uicolor colorwithhexstring:@"#e4e4e8"].cgcolor; cell.layer.shadowradius = 0; return cell; }
i try add [cell.contentview layoutifneeded];
still same.
any appreciated.
Comments
Post a Comment