簡體   English   中英

uitableview滾動覆蓋uilabel的文本顏色

[英]uitableview scrolling override the textcolor of uilabel

我正在重寫UIlabel的顏色,它是onmy tableview自定義單元格。 當我滾動tableview時,文本會被覆蓋。

覆蓋文本顏色“塔沒有響應”

嘗試將為標簽上色的代碼放在單元類的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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM