From 202f968b98e87e130c58116b82f76282112e53f6 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 14 Sep 2019 12:59:40 -0700 Subject: [PATCH] Rework app labels on iOS to reuse title UILabel and use correct size and insets --- Limelight/UIAppView.m | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Limelight/UIAppView.m b/Limelight/UIAppView.m index 2a61b378..1d9f0702 100644 --- a/Limelight/UIAppView.m +++ b/Limelight/UIAppView.m @@ -147,25 +147,26 @@ static UIImage* noImage; } if (noAppImage) { +#if TARGET_OS_TV _appLabel = [[UILabel alloc] init]; [_appLabel setTextColor:[UIColor whiteColor]]; + [_appLabel setText:_app.name]; + [_appLabel setFrame:self.frame]; +#else + _appLabel = _appButton.titleLabel; + [_appButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + [_appButton setTitle:_app.name forState:UIControlStateNormal]; + [_appButton setTitleEdgeInsets:UIEdgeInsetsMake(_appOverlay != nil ? _appOverlay.frame.size.height : 5, 5, 5, 5)]; +#endif + [_appLabel setFont:[UIFont systemFontOfSize:24]]; [_appLabel setBaselineAdjustment:UIBaselineAdjustmentAlignCenters]; [_appLabel setTextAlignment:NSTextAlignmentCenter]; [_appLabel setLineBreakMode:NSLineBreakByWordWrapping]; [_appLabel setNumberOfLines:0]; - [_appLabel setText:_app.name]; #if TARGET_OS_TV - [_appLabel setFont:[UIFont systemFontOfSize:24]]; - [_appLabel setFrame: self.frame]; - [_appButton addSubview:[self renderToImageView:noImage]]; #else - // This padding doesn't work on Apple TV due to how we render into an ImageView - CGFloat padding = 4.f; - [_appLabel setFrame: CGRectMake(padding, padding, _appButton.frame.size.width - 2 * padding, _appButton.frame.size.height - 2 * padding)]; - - [_appButton addSubview:_appLabel]; [self addSubview:_appOverlay]; #endif }