테이블 뷰에서 선택한 행 색상이 변경되지 않는 이유를 알 수 없습니다.선택한 행의 배경색이 변경되지 않음
셀의 배경에 사용자 지정 셀을 적용하고 그라디언트 색을 적용했으며 선택한 배경을 사용하여 bgcolor를 변경하는 코드를 작성했습니다. 문제는 제가 그라디언트 색상을 사용하지 않았다면 잘 작동하지만 그래디언트 색상을 사용하면 bgcolor가 바뀌지 않는 것입니다.
정확한 문제는 무엇입니까 ?? 이것에 대한 모든 솔루션 ??
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *[email protected]"ViewProfileCell";
MyHomeViewCell *cell= [[MyHomeViewCell alloc] init];
cell=(MyHomeViewCell*)[tableView dequeueReusableCellWithIdentifier:cellidentifier];
if(!cell)
{
NSArray *nibofMyHomeCell=[[NSBundle mainBundle]loadNibNamed:@"MyHomeViewCell" owner:self options:Nil];
cell=[nibofMyHomeCell objectAtIndex:0];
}
UIView *v=[[UIView alloc]init];
v.layer.backgroundColor=[[UIColor colorWithRed:46.0/255.0f green:139.0/255.0f blue:87.0/255.0f alpha:1 ]CGColor];
cell.selectedBackgroundView=v;
CAGradientLayer *ViewGradient=[CAGradientLayer layer];
ViewGradient.frame=CGRectMake(0, 0, 320, 52);
ViewGradient.colors = [NSArray arrayWithObjects:
(id)[[UIColor colorWithRed:27.0f/255.0f green:48.0f/255.0f blue:39.0f/255.0f alpha:1.0f] CGColor],
(id)[[UIColor colorWithRed:26.0f/255.0f green:47.0f/255.0f blue:38.0f/255.0f alpha:1.0f] CGColor],
(id)[[UIColor colorWithRed:25.0f/255.0f green:44.0f/255.0f blue:37.0f/255.0f alpha:1.0f] CGColor],
(id)[[UIColor colorWithRed:23.0f/255.0f green:42.0f/255.0f blue:35.0f/255.0f alpha:1.0f] CGColor],
(id)[[UIColor colorWithRed:22.0f/255.0f green:41.0f/255.0f blue:34.0f/255.0f alpha:1.0f] CGColor],
(id)[[UIColor colorWithRed:22.0f/255.0f green:40.0f/255.0f blue:33.0f/255.0f alpha:1.0f] CGColor],
nil];
[cell.layer insertSublayer:ViewGradient atIndex:0];
cell.layer.shadowColor = [[UIColor whiteColor] CGColor];
cell.layer.shadowOpacity=20.0f;
cell.layer.borderWidth=1.0f;
cell.layer.borderColor=[[UIColor colorWithRed:38.0f/255.0f green:70.0f/255.0f blue:58.0f/255.0f alpha:1.0f] CGColor];
}
동일한 문제가 발생하지 않습니다. –