0
我正在使用SBTableAlert(请参阅:https://github.com/mindbrix/SBTableAlert)并想知道是否可以更改高亮显示的颜色。目前它是蓝色的,但我更喜欢另一个。我还希望让选项文字稍微小一些,而不是粗体,但我不知道它的设置。是否可以修改SBTableAlert的高亮颜色和字体大小?
谢谢!
我正在使用SBTableAlert(请参阅:https://github.com/mindbrix/SBTableAlert)并想知道是否可以更改高亮显示的颜色。目前它是蓝色的,但我更喜欢另一个。我还希望让选项文字稍微小一些,而不是粗体,但我不知道它的设置。是否可以修改SBTableAlert的高亮颜色和字体大小?
谢谢!
里面SBTableAlert.m找到如下:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
在那里,你可以只包括这和你的背景颜色会被改变:
//Example with a predefined color
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor redColor]];
[self setSelectedBackgroundView:bgColorView];
或
//Example with an RGB color
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor colorWithRed:155.0f/255.0f green:155.0f/255.0f blue:155.0f/255.0f alpha:1.0f]];
[self setSelectedBackgroundView:bgColorView];
只需添加这行到RootViewController.m在这种方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if ([indexPath row] == 1)
{
[cell.textLabel setText:@"Single Select"];
cell.textLabel.font = [cell.textLabel.font fontWithSize:10];
}
else if ([indexPath row] == 0){
[cell.textLabel setText:@"Multiple Select"];
cell.textLabel.font = [cell.textLabel.font fontWithSize:10];}
else if ([indexPath row] == 2){
[cell.textLabel setText:@"Apple Style"];
cell.textLabel.font = [cell.textLabel.font fontWithSize:10];}
else if ([indexPath row] == 3){
[cell.textLabel setText:@"Sections"];
cell.textLabel.font = [cell.textLabel.font fontWithSize:10];}
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor redColor];
[cell setSelectedBackgroundView:bgColorView];
return cell;
}
这将改变主要tableview,而不是alertview表。 –