用UITableViewCellSelectionStyleGrayselect颜色的UIButton
我试图设置一个UIButton的颜色为'UITableViewCellSelectionStyleGray'; 问题是,UIButton的select颜色不能设置,只有图像。 有谁知道如何使图像与UITableViewCellSelectionStyleGray所选单元格的确切颜色?
不幸的是我似乎无法通过编程的方式find实际的颜色,但DigitalColor Meter(OSX APP)表示颜色为217 217 217
UIColor* selectedColor = [UIColor colorWithRed:217.0/255.0 green:217.0/255.0 blue:217.0/255.0 alpha:1.0];
尝试这个:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50, 50, 60, 20); button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"orange.jpg"]]; [self.view addSubview:button];
在UIButton
上设置tintColor
属性时,颜色设置为突出显示的状态。 所以你可以这样做:
[button setTintColor:[UIColor lightGrayColor]];
然而, lightGrayColor
可能不是你正在寻找的确切的灰色。 我不知道有一种方法来获得一个UITableViewCell
的确切的select灰色的参考。 你可能只需要玩[UIColor colorWithRed:green:blue:alpha:]
来得到它想要的。
**也不是说tintColor
属性在iOS 7有不同的含义,所以要小心,如果你使用这个代码。