[英]How to ressolve iOS UITableView Override UILabel and UITextField on Scrolling?
[英]uitableview scrolling override the textcolor of uilabel
嘗試將為標簽上色的代碼放在單元類的awakeFromNib中,而不是在cellForRow內,因為由於出隊,顏色漸變被多次添加到標簽中
感謝您的回答,我為它創建了2個單元格。1.閃爍紅色2.第二種靜態文本顏色現在數據沒有重疊,並且單元格正確顯示且具有閃爍效果。
而且工作正常。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {static NSString * strCellId = @“ HomeControllerCell”; HomeControllerCell * cell = [tableView dequeueReusableCellWithIdentifier:strCellId];
static NSString *strCellBlink = @"HomeControllerCellBlink";
HomeControllerCell *cellBlink = [tableView dequeueReusableCellWithIdentifier:strCellBlink];
NSDictionary *dictTemp = [arrayData objectAtIndex:indexPath.row];
NSString * strDispatchColor = @“”; if([dictTemp objectForKey:@“ DispatchColor”]!= nil &&![[dictTemp objectForKey:@“ DispatchColor”] isKindOfClass:[NSNull class]]){strDispatchColor = [dictTemp objectForKey:@“ DispatchColor”];
if ([[NSString stringWithFormat:@"%@",strDispatchColor] isEqualToString:KColorRed]) {
cell.lblStatus.textColor = [UIColor redColor];
} else if ([[NSString stringWithFormat:@"%@",strDispatchColor] isEqualToString:KColorGreen]) {
cell.lblStatus.textColor = [UIColor greenColor];
}else if ([[NSString stringWithFormat:@"%@",strDispatchColor] isEqualToString:KColorYellow]) {
cell.lblStatus.textColor = [UIColor yellowColor];
}else if ([[NSString stringWithFormat:@"%@",strDispatchColor] isEqualToString:KColorWhite]) {
cell.lblStatus.textColor = [UIColor whiteColor];
cell.lblStatus.shadowColor = [UIColor colorWithRed:38.0/255.0 green:102.0/255.0 blue:149.0/255.0 alpha:1.0];
cell.lblStatus.shadowOffset = CGSizeMake(1.2, 1.2);
}else if ([[NSString stringWithFormat:@"%@",strDispatchColor] isEqualToString:KColorFlashingRed]){
// Blinking animation
dispatch_queue_t downloadQueue=dispatch_queue_create("textShowing", NULL);
dispatch_async(downloadQueue, ^{
dispatch_async(dispatch_get_main_queue(), ^{
// store the downloaded image in your model
cellBlink.lblStatus.alpha = 1;
cellBlink.lblStatus.textColor = [UIColor redColor];
[UIView animateWithDuration:0.9 delay:0.0 options:UIViewAnimationOptionRepeat animations:^{
cellBlink.lblStatus.alpha = 0;
} completion:nil];
});
});
return cellBlink;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.