风格UITableViewCell(尝试复制Facebook iPhone应用程序外观)

时间:2012-03-23 10:12:32

标签: iphone facebook uitableview

在Facebook iPhone应用程序上,左侧有一个滑动视图,显示UITableView

我正在尝试复制这张桌子的外观,每个单元格都有一个似乎是自定义的边框(看起来像一条非常纤细的浅灰色和黑色线条?)。此外,在选择单元格时,单元格会以深灰色突出显示,而不是默认的蓝色。

enter image description here

我尝试在stackoverflow上搜索,确实有一个类似的问题,但只有两个回复回复使用Three20库。

我想知道如何使用UIKit实现相同的外观,而不必使用Three20库。

非常感谢有关如何重现这种特定风格UITableViewCell的任何帮助!

编辑#1:为了澄清,我知道如何使用图像和文本制作UITableViewCells。我不知道该怎么做的部分是自定义边框和选择颜色,使其看起来像Facebook示例图像。

编辑#2:只是为了确定,我也不会问如何制作幻灯片视图。我只是根据Facebook iphone应用程序的屏幕截图询问如何设置表格样式。 :)

谢谢!

2 个答案:

答案 0 :(得分:1)

可以使用自定义行的图像和滑动效果的动画来完成

答案 1 :(得分:0)

这是一个带有左右菜单的Slider,显然你可以像我一样在代码中禁用正确的菜单!

滑出菜单:DDMenuController

这是我做过的一些看起来像FB一样的自定义,而不是图片!

LeftController.m

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

- (void)viewDidLoad {
[super viewDidLoad];

navBarMenuArray = [[NSArray alloc] initWithObjects:
                   @"My Photos",
                   @"My Friends",
                   @"Inbox",
                   @"Stores",
                   @"Offers",
                   @"Settings",nil];

navBarImagesArray = [[NSArray alloc] initWithObjects:
                     @"photos.jpg",
                     @"friends.jpg",
                     @"inbox.jpg",
                     @"stores.jpg",
                     @"settings.jpg", nil];

searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 240.0, 45.0)];
searchBar.tintColor = UIColorFromRGB(0x0075bb);
searchBar.placeholder = @"Search a brand or store...";
[self.view addSubview:searchBar];
[searchBar release];

if (!_tableView) {
    //UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];

    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 44, 320, 506) style:UITableViewStylePlain];
    tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    tableView.delegate = (id<UITableViewDelegate>)self;
    tableView.dataSource = (id<UITableViewDataSource>)self;
    [self.view addSubview:tableView];
    self.tableView = tableView;
    }
}

- (void)viewDidUnload {
[super viewDidUnload];
self.tableView = nil;
}

- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
    return navBarMenuArray.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.textLabel.font = [UIFont fontWithName:@"ArialMT" size:17];
    cell.textLabel.text = [navBarMenuArray objectAtIndex:indexPath.row];
    cell.textLabel.textColor = UIColorFromRGB(0xa2a9b9);
    cell.textLabel.shadowColor = UIColorFromRGB(0x212838);
    cell.textLabel.shadowOffset = CGSizeMake(1.0, 1.0);
    cell.textLabel.backgroundColor = UIColorFromRGB(0x32394b);
    self.tableView.backgroundColor = UIColorFromRGB(0x32394b);
    self.tableView.separatorColor = UIColorFromRGB(0x262d3d);
    return cell;
}