2012-03-23 27 views
3

在Facebook iPhone應用程序的左側有一個滑動視圖,其中顯示了UITableView風格的UITableViewCell(試圖複製Facebook iPhone應用程序外觀)

我試圖複製這張表的外觀,每個單元格都有自定義的邊框(看起來像一條非常纖細的淺灰色和黑色的線條?)。另外,在選擇單元格時,單元格突出顯示爲深灰色,而不是默認的藍色。

enter image description here

我試着搜索計算器,確實也有類似的問題,但只有兩個答覆說使用Three20庫。

我想知道如何用UIKit實現這種相同的外觀,而不必使用Three20庫。

任何有關如何重現UITableViewCell特定風格的幫助將不勝感激!

編輯#1:澄清,我知道如何使UITableViewCells自己,與圖像和文字。我不知道該怎麼做的部分是自定義邊框和選擇顏色,使其看起來像Facebook的示例圖像。編輯#2:只是可以肯定,我也不問如何製作幻燈片視圖。我只是問如何根據Facebook iPhone應用下面的屏幕截圖來設置桌子的樣式。 :)

謝謝!

回答

1

它可以通過使用自定義行和動畫圖像爲它的滑動效果

+0

我正要提出,在一個編輯。我發現這個鏈接:http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html,似乎他只是使用圖像的行。因此,除了每行使用圖像之外,您可以使用UIKit做什麼?我認爲可能會有一些CALayer的詭計...... – kurisukun 2012-03-23 11:03:49

+0

actully你可以改變單元格背景和分隔符的顏色,但是這不會給你你正在尋找的感覺。爲此目的,使用圖像是最好的選擇,也是最簡單的選擇,它會給你帶來同樣的效果 – 2012-03-23 11:17:34

+0

謝謝,這正是我懷疑的! :) – kurisukun 2012-03-23 11:32:27

0

這裏是左右菜單滾動條來實現,可以很明顯的禁用正確的代碼像我一樣!

滑出式菜單: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; 
} 
相關問題