mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 14:11:35 +00:00
fix: apply tvos style to missing icon
This commit is contained in:
+21
-4
@@ -125,18 +125,35 @@ static UIImage* noImage;
|
|||||||
|
|
||||||
if (noAppImage) {
|
if (noAppImage) {
|
||||||
_appLabel = [[UILabel alloc] init];
|
_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 setTextColor:[UIColor whiteColor]];
|
||||||
[_appLabel setBaselineAdjustment:UIBaselineAdjustmentAlignCenters];
|
[_appLabel setBaselineAdjustment:UIBaselineAdjustmentAlignCenters];
|
||||||
[_appLabel setTextAlignment:NSTextAlignmentCenter];
|
[_appLabel setTextAlignment:NSTextAlignmentCenter];
|
||||||
[_appLabel setLineBreakMode:NSLineBreakByWordWrapping];
|
[_appLabel setLineBreakMode:NSLineBreakByWordWrapping];
|
||||||
[_appLabel setNumberOfLines:0];
|
[_appLabel setNumberOfLines:0];
|
||||||
|
[_appLabel setText:_app.name];
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
[_appLabel setFont:[UIFont systemFontOfSize:16]];
|
[_appLabel setFont:[UIFont systemFontOfSize:16]];
|
||||||
#endif
|
[_appLabel setAdjustsFontSizeToFitWidth:YES];
|
||||||
[_appLabel setText:_app.name];
|
[_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];
|
[_appButton addSubview:_appLabel];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user