這裏是左右菜單滾動條來實現,可以很明顯的禁用正確的代碼像我一樣!
滑出式菜單: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;
}
我正要提出,在一個編輯。我發現這個鏈接:http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html,似乎他只是使用圖像的行。因此,除了每行使用圖像之外,您可以使用UIKit做什麼?我認爲可能會有一些CALayer的詭計...... – kurisukun 2012-03-23 11:03:49
actully你可以改變單元格背景和分隔符的顏色,但是這不會給你你正在尋找的感覺。爲此目的,使用圖像是最好的選擇,也是最簡單的選擇,它會給你帶來同樣的效果 – 2012-03-23 11:17:34
謝謝,這正是我懷疑的! :) – kurisukun 2012-03-23 11:32:27