// // Cell_Meteo_TableViewCell.m // Earthquake Network // // Created by Luca Beretta on 01/11/18. // Copyright © 2018 Luca Beretta. All rights reserved. // #import "Cell_Meteo_TableViewCell.h" #import @implementation Cell_Meteo_TableViewCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(void)setupView{ [super setupView]; NSString *temp = NSLocalizedString(@"Temperatura: ", @""); NSString *valueTemp = [NSString stringWithFormat:@"%1.f °C", [self.sisma.weatherTemperature floatValue]-273]; NSString *tempDesc = [NSString stringWithFormat:@"%@%@", temp, valueTemp]; NSString *pres = NSLocalizedString(@"Pressione:", @""); NSString *valuePre = [NSString stringWithFormat:@"%@mb", self.sisma.weatherPressure]; NSString *presDesc = [NSString stringWithFormat:@"%@%@",pres, valuePre]; NSString *vent = NSLocalizedString(@"Velocità vento: ", @""); NSString *valueVento = [NSString stringWithFormat:@"%@m/s", self.sisma.weatherWindSpeed]; NSString *ventoDesc = [NSString stringWithFormat:@"%@%@", vent, valueVento]; NSString *umi = NSLocalizedString(@"Umidità : ", @""); NSString *umiValue = [NSString stringWithFormat:@"%@%%", self.sisma.weatherHumidity]; NSString *umiditaDesc = [NSString stringWithFormat:@"%@%@", umi, umiValue]; NSString *nuv = NSLocalizedString(@"Copertura nuvolosa : ", @""); NSString *nuvValue = [NSString stringWithFormat:@"%@%%", self.sisma.weatherCloud]; NSString *nuvolDesc = [NSString stringWithFormat:@"%@%@",nuv, nuvValue]; UILabel *titolo = (UILabel *)[self viewWithTag:20]; titolo.text = NSLocalizedString(@"Meteo al momento del sisma", @""); UILabel *temperatura = (UILabel *)[self viewWithTag:21]; temperatura.attributedText = [self getAttributeString:tempDesc withRange:NSMakeRange(temp.length, valueTemp.length)]; UILabel *pressione = (UILabel *)[self viewWithTag:22]; pressione.attributedText = [self getAttributeString:presDesc withRange:NSMakeRange(pres.length, valuePre.length)]; UILabel *vento = (UILabel *)[self viewWithTag:23]; vento.attributedText = [self getAttributeString:ventoDesc withRange:NSMakeRange(vent.length, valueVento.length)]; UILabel *umidita = (UILabel *)[self viewWithTag:24]; umidita.attributedText = [self getAttributeString:umiditaDesc withRange:NSMakeRange(umi.length, umiValue.length)]; UILabel *nuvolosita = (UILabel *)[self viewWithTag:25]; nuvolosita.attributedText = [self getAttributeString:nuvolDesc withRange:NSMakeRange(nuv.length, nuvValue.length)]; UIImageView *icona = (UIImageView *)[self viewWithTag:26]; NSString *imagName = [NSString stringWithFormat:@"weather_%@.png", self.sisma.weatherIcon]; icona.image = [UIImage imageNamed:imagName]; } -(NSMutableAttributedString *)getAttributeString:(NSString *)string withRange:(NSRange )range{ NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string]; [attrString beginEditing]; [attrString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:17] range:range]; [attrString endEditing]; return attrString; } @end