【发布时间】:2014-03-11 03:12:56
【问题描述】:
如何创建一个除了图像之外透明的 UIButton?
我有透明背景的 PNG。我用它创建了一个按钮,然后我得到了蓝色的图像。
如果我将 tintColor 设置为 clearColor,色调会消失,但黑色图像也会消失。
我一直使用 UIButtonTypeSystem 作为按钮类型。
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem] ;
button.frame = rect ;
[button setImage:image forState:UIControlStateNormal] ;
button.backgroundColor = [UIColor clearColor] ; // Does nothing
button.tintColor = [UIColor clearColor] ; // Makes the button go away.
【问题讨论】: