Showing posts with label Section. Show all posts
Showing posts with label Section. Show all posts
Wednesday, 5 March 2014
How to add separator line to UITableView Section
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view; CGRect sepFrame = CGRectMake(0, view.frame.size.height-1, 320, 1); UIView *seperatorView =[[UIView alloc] initWithFrame:sepFrame]; seperatorView.backgroundColor = [UIColor colorWithWhite:224.0/255.0 alpha:1.0]; [header addSubview:seperatorView];
Tuesday, 4 March 2014
UITableView - change section header color iOS 6 and up
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
view.tintColor = [UIColor clearColor];
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor whiteColor]];
}
{
view.tintColor = [UIColor clearColor];
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor whiteColor]];
}
Labels:
Header,
iOS 6,
ios 7,
Section,
TableViewCell,
UITableView
UITableView with Multiple Sections
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2 ;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section==0)
{
return [array1 count];
}
else{
return [array2 count];
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if(section == 0)
return @"Section 1";
if(section == 1)
return @"Section 2";
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
if (indexPath.section==0) {
ObjectData *theCellData = [array1 objectAtIndex:indexPath.row];
Subscribe to:
Posts (Atom)