동적 개체로 채워져 사용자 정의 테이블 뷰가 작성되어 목록을 구성합니다. 내 셀에서 이미지의 절반 상단에 그라디언트 오버레이를 설정하려고합니다.IOS 그라데이션 오버레이를 스크롤하면 단색이됩니다.
interface.builder에서 내 레이아웃을 설정했습니다.
아래 질문은 : - 내 그라디언트 오버레이가 위/아래로 스크롤 한 후 단색 오버레이가되도록 유도 할 때마다 다시 그려지는 문제가 있습니다. 누구든지 이것을 극복하는 방법을 알고 있습니까?
감사합니다.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
CustomTableViewCell *cell = (CustomTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"TableCellId"];
if(cell == nil){
cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TableCellId"];
}
UIImageView *item_image = (UIImageView *)[cell viewWithTag:@"cell_image"];
NSString *url_image = [NSString stringWithFormat:@"%@%@", URL_SERVER_HOST, item_pic];
[item_image setImageWithURL:[NSURL URLWithString:url_image]];
//Currently get called when new cell is loaded
UIView *overlay = (UIView *)[cell viewWithTag:@"cell_overlay"];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = overlay.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor clearColor] CGColor], (id)[[UIColor blackColor] CGColor], nil];
[overlay.layer insertSublayer:gradient atIndex:0];
UILabel * item_name = (UILabel *)[cell viewWithTag:@"cell_name"];
item_name.text = @"test text";
return cell;
}
나는 그것을 시도했지만 어떻게 든 세포는 스토리 보드를 사용하거나있는 tableview에 펜촉을 등록 세포를 만드는 경우 – bruce
을 호출되지 않을 그라데이션 원인에 이동, 전무 결코 전에 선 아래 쓰기, 당신은 추가 할 수 있습니다 셀 클래스의 -awakeFromNib 메소드의 그래디언트 레이어 그렇지 않으면 -initWithStyle : reuseIdentifier에 그라디언트 레이어를 추가 할 수 있습니다. – Oscar