【发布时间】:2015-12-18 21:31:45
【问题描述】:
我UIButtons 上面有图片和标题。我正在使用appearanceWhenContainedInInstancesOfClasses: 更改应用程序中的主题。当我根据我想要的主题更改 UIButton 的背景和标题颜色时,它会在 UIButton 的标题和图像后面留下一些白色背景(下图显示它)。
如何去掉按钮标签和图片后面的白色背景?
【问题讨论】:
标签: ios objective-c uibutton
我UIButtons 上面有图片和标题。我正在使用appearanceWhenContainedInInstancesOfClasses: 更改应用程序中的主题。当我根据我想要的主题更改 UIButton 的背景和标题颜色时,它会在 UIButton 的标题和图像后面留下一些白色背景(下图显示它)。
如何去掉按钮标签和图片后面的白色背景?
【问题讨论】:
标签: ios objective-c uibutton
您可以为每个按钮使用以下代码。
btn.backgroundColor = [UIColor clearColor];
btn.opaque = NO;
详细说明:
问题的根源在于,按钮的默认背景颜色是白色,因此一旦将背景颜色/主题应用于按钮所在的 UIView,白色就会变得可见且看起来不太好。因此,我建议将 btw 颜色 clearColor 或 UIView 颜色更改为白色。
【讨论】:
[[UIView appearanceWhenContainedInInstancesOfClasses:@[[GoogleAdsViewController class]]] setBackgroundColor:[UIColor whiteColor]];。我发现这是导致问题的原因。不知道如何解决这个问题。
[[UIView appearanceWhenContainedInInstancesOfClasses:@[[GoogleAdsViewController class]]] setBackgroundColor:[UIColor clearColor]];
您可能已将按钮的图像设置为背景,或者您的图像本身具有白色背景。
【讨论】: