fix: apply tvos style to missing icon

This commit is contained in:
Andrew Scagnelli
2018-10-24 00:08:06 -04:00
parent dedcbd9d3e
commit c2134585df

View File

@@ -125,18 +125,35 @@ static UIImage* noImage;
if (noAppImage) {
_appLabel = [[UILabel alloc] init];
CGFloat padding = 4.f;
[_appLabel setFrame: CGRectMake(padding, padding, _appButton.frame.size.width - 2 * padding, _appButton.frame.size.height - 2 * padding)];
[_appLabel setTextColor:[UIColor whiteColor]];
[_appLabel setBaselineAdjustment:UIBaselineAdjustmentAlignCenters];
[_appLabel setTextAlignment:NSTextAlignmentCenter];
[_appLabel setLineBreakMode:NSLineBreakByWordWrapping];
[_appLabel setNumberOfLines:0];
[_appLabel setText:_app.name];
#if TARGET_OS_TV
[_appLabel setFont:[UIFont systemFontOfSize:16]];
#endif
[_appLabel setText:_app.name];
[_appLabel setAdjustsFontSizeToFitWidth:YES];
[_appLabel setFrame: CGRectMake(0, 0, 200, 265)];
//custom image to do TvOS hover popup effect
UIImageView *imageView = [[UIImageView alloc] initWithImage:appImage];
imageView.userInteractionEnabled = YES;
imageView.adjustsImageWhenAncestorFocused = YES;
imageView.frame = CGRectMake(0, 0, 200, 265);
UIGraphicsBeginImageContextWithOptions(_appLabel.frame.size, false, 0);
[imageView.layer renderInContext:(UIGraphicsGetCurrentContext())];
[_appLabel.layer renderInContext:(UIGraphicsGetCurrentContext())];
UIImage *imageWithText = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[imageView setImage:imageWithText];
[_appButton addSubview:imageView];
_appButton.frame = CGRectMake(0, 0, 200, 265);
self.frame = CGRectMake(0, 0, 200, 265);
#else
CGFloat padding = 4.f;
[_appLabel setFrame: CGRectMake(padding, padding, _appButton.frame.size.width - 2 * padding, _appButton.frame.size.height - 2 * padding)];
[_appButton addSubview:_appLabel];
#endif
}
}