中心垂直的UILabel文本如何更改tableview中部分文本的位置?我用viewForHeaderInSection:第一部分,我創建有somwthing這樣的:在表視圖節頭
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
label.backgroundColor = [UIColor blackColor];
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"Gotham-Bold" size:17.0f];
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.comlpetedFetchedResultsController sections] objectAtIndex:section];
label.text = [@" " stringByAppendingString:[sectionInfo name]];
return label;
}
它不事關什麼尺寸是的UILabel幀的參數,我總是得到相同的結果:
哪有我在UILabel垂直居中文本? 感謝
你可以看到文字是黑色的UILabel的頂部,我希望把它中心(一點點下來,現在) – edzio27
你有沒有嘗試在中心使用的標籤標籤的文本。 textAlignment = UITextAlignmentCenter – Jbryson
您是否嘗試更改y? UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0,3,300,30)]; –