当我单击 uitableview 单元格时,该单元格的文本会变粗。我能做些什么?
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UIView * selected = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 100)];
[selected setBackgroundColor: [UIColor colorWithRed: 234/255.0f green: 234/255.0f blue: 234/255.0f alpha: 1.0]];
cell.selectedBackgroundView = selected;
NSDictionary * val = [self.entries objectAtIndex: indexPath.row];
UIView * cellview = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 85)];
[cellview setBackgroundColor: [UIColor whiteColor]];
NSString * namet = @"";
NSString * pitcht = @"";
NSString * category = @"";
NSString * first_name = @"";
NSString * last_name = @"";
NSString * photo = @"";
NSDictionary * investor;
NSDictionary * startup;
float miles = 0;
NSDictionary * user;
if(showInvestors)
{
if ([val objectForKey: @"investor"] &&
[val objectForKey: @"investor"]!= (id)[NSNull null])
{
investor = [val objectForKey: @"investor"];
if ([investor objectForKey: @"user"] &&
[investor objectForKey: @"user"] != (id)[NSNull null])
{
user = [investor objectForKey: @"user"];
first_name = [user objectForKey: @"first_name"];
last_name = [user objectForKey: @"last_name"];
namet = [NSString stringWithFormat: @"%@ %@", first_name, last_name];
}
if ([investor objectForKey: @"bio"] &&
[investor objectForKey: @"bio"] != (id)[NSNull null])
{
pitcht = [investor objectForKey: @"bio"];
}
if ([investor objectForKey: @"category_list"] &&
[investor objectForKey: @"category_list"] != (id)[NSNull null])
{
category = [investor objectForKey: @"category_list"];
}
if ([investor objectForKey: @"photo_url"] &&
[investor objectForKey: @"photo_url"] != (id)[NSNull null])
{
photo = [investor objectForKey: @"photo_url"];
}
}
}
else
{
if ([val objectForKey: @"startup"] &&
[val objectForKey: @"startup"] != (id)[NSNull null])
{
startup = [val objectForKey: @"startup"];
}
if ([startup objectForKey: @"name"] &&
[startup objectForKey: @"name"] != (id)[NSNull null])
{
namet = [startup objectForKey: @"name"];
}
if ([startup objectForKey: @"pitch"] &&
[startup objectForKey: @"pitch"] != (id)[NSNull null])
{
pitcht = [startup objectForKey: @"pitch"];
}
if ([startup objectForKey: @"categories"] &&
[startup objectForKey: @"categories"] != (id)[NSNull null] &&
[[[startup objectForKey: @"categories"] objectAtIndex: 0] objectForKey: @"name"] &&
[[[startup objectForKey: @"categories"] objectAtIndex: 0] objectForKey: @"name"] != (id)[NSNull null])
{
category = [[[startup objectForKey: @"categories"] objectAtIndex: 0] objectForKey: @"name"];
}
if ([startup objectForKey: @"photo_url"] &&
[startup objectForKey: @"photo_url"] != (id)[NSNull null])
{
photo = [investor objectForKey: @"photo_url"];
}
}
UIImageView * midview = [[UIImageView alloc] initWithFrame: CGRectMake(10, 15, 50, 50)];
if(photo.length >= 1)
{
NSURL *url = [[NSURL alloc] initWithString: photo];
[midview setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar"]];
[midview.image imageCroppedToFitSize: CGSizeMake(60, 60)];
}
[cellview addSubview: midview];
UILabel * name = [[UILabel alloc] initWithFrame: CGRectMake(70, 15, 150, 16)];
[name setText: namet];
[name setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 16.0f]];
[name setTextColor: [UIColor colorWithRed: 79.0/255.0f green: 79.0/255.0f blue: 79.0/255.0f alpha: 1.0]];
UILabel * pitch = [[UILabel alloc] initWithFrame: CGRectMake(70, 31, 200, 26)];
[pitch setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 12.0f]];
[pitch setText: pitcht];
pitch.numberOfLines = 1;
[pitch setTextColor: [UIColor colorWithRed: 79.0/255.0f green: 79.0/255.0f blue: 79.0/255.0f alpha: 1.0]];
UIImage * play = [UIImage imageNamed: @"e_play.png"];
UIImageView * playview = [[UIImageView alloc] initWithImage: play];
[playview setFrame: CGRectMake(280, 20, play.size.width, play.size.height)];
[cellview addSubview: name];
[cellview addSubview: pitch];
[cellview addSubview: playview];
NSString * catstr = [NSString stringWithFormat: @"Industry: %@", category];
UILabel * catlb = [[UILabel alloc] initWithFrame: CGRectMake(70, 58, 180, 14)];
[catlb setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 12.0f]];
[catlb setText: catstr];
[catlb setTextColor: [UIColor colorWithRed: 79.0/255.0f green: 79.0/255.0f blue: 79.0/255.0f alpha: 1.0]];
[cellview addSubview: catlb];
if ([val objectForKey: @"latitude"] &&
[val objectForKey: @"latitude"] != (id)[NSNull null] &&
[val objectForKey: @"longitude"] &&
[val objectForKey: @"longitude"] != (id)[NSNull null])
{
CLLocationDegrees slatitude = [[val objectForKey: @"latitude"] doubleValue];
CLLocationDegrees slongitude = [[val objectForKey: @"longitude"] doubleValue];
CLLocationDistance distance = [self myDistanceFromLatitude: slatitude longitude: slongitude];
if(distance > 0)
{
miles = [self convertToMiles: distance];
}
}
NSString * distancetxt = [NSString stringWithFormat: @"%1.1f miles", miles];
UILabel * dislb = [[UILabel alloc] initWithFrame: CGRectMake(220, 15, 50, 16)];
[dislb setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 11.0f]];
[dislb setText: distancetxt];
[dislb sizeToFit];
[dislb setTextColor: [UIColor colorWithRed: 79.0/255.0f green: 79.0/255.0f blue: 79.0/255.0f alpha: 1.0]];
[cellview addSubview: dislb];
[cell addSubview: cellview];
return cell;
这是我上面的 cellForRowAtIndexPath 代码。
当我单击一个单元格时,单元格的文本会变得更清晰......
我能做些什么?
如何做到这一点,以便当我选择一个单元格时它不会变得更粗或更锐利?谢谢。