我想创建一个 UILabel
并将其背景设置为渐变蓝色,就像选定的 UITableViewCell
一样。我怀疑我需要使用 UIColor colorWithPatternImage:
。如果是,我不确定获取图案图像的最佳方法是什么。或者,关于如何实现这一点的任何其他建议?
我不想创建预渲染的背景图像,因为我需要它在 iPhone 3GS、4 和 iPad 上工作,它们都需要不同的背景图像。
最佳答案
Apple 使用的图像是 UITableSelection.png。我附上了标准和@2x 图片。
UIView *selectedView = [[UIView alloc] initWithFrame:self.bounds];
selectedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"UITableSelection.png"]];
cell.selectedBackgroundView = selectedView;
关于iphone - 创建类似于所选 UITableViewCell 的 UILabel 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4558508/