2013-06-19 3 views
-1

좋아요, 그래서 저는 개발시에 uber noob이지만 Xcode를 배우려고합니다. 내가 아직 알아 내야 할 한가지는 SectionHeader (Color Font 's Etc.)를 변경하는 방법입니다. Container에 포함 된 TableView를 사용하고 있습니다. 그리고 구체적으로 말하자면 내 섹션 헤더는 알파벳 A-Z이며 "Helvetica Neue UltraLight"글꼴 및 글꼴 크기 24로 만들려고합니다. 글꼴, 글꼴 크기 및 글꼴 색을 어떻게 변경합니까?SectionHeader를 사용자 정의하는 방법

또한 섹션 헤더의 배경색을 완전히 지우려고합니다.

저는 Xcode 4.6.3을 사용하고 있습니다. iOS 6.1 용 앱 만들기.

+0

죄송합니다. 가혹한 것처럼 보일지 모르지만 ** 그 **를 모르는 경우 Objective-C와 'Foundation Framework'(및 기타)를 배우면서 맨 처음부터 시작하는 것이 좋습니다. 아이폰 개발로 뛰어 들기보다 ... – HAS

답변

2

재정의있는 tableView : viewForHeaderInSection : 당신의있는 UITableViewController에 :

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
     UIFont *font = [UIFont fontWithName:@"Helvetica Neue UltraLight" size:24]; 
     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 3, tableView.bounds.size.width - 10, 33)]; 
     label.font = font; 
     label.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.75]; 
     label.backgroundColor = [UIColor clearColor]; 
     label.text = @"A"; 
     UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, TableView.bounds.size.width, 44)]; 
     [headerView addSubview:label]; 
     [headerView setBackgroundColor:[UIColor clearColor]]; 
     return headerView; 
} 

당신은 적절 섹션 헤더에서 원하는 텍스트를 기반으로 프레임 높이를 조정해야합니다. 올바른 높이 값을 계산하려면 NSString sizeWithFont : constrainedToSize : lineBreakMode :를 사용하십시오.

+0

더 설명 할 수 있을까요, 내가 무엇을하고 있는지 정말로 모르겠습니다. 고맙습니다. – user2502850

관련 문제