我想在UITableView
中添加一個類似於附加圖像(LHR-SYD/372結果)的固定透明標頭。這是xcode/ios中的「內置」組件嗎?或者它是如何完成的?在UITableView中固定透明標頭
3
A
回答
7
使用這些方法中,
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
上述用於設置視圖方法。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
以上設置標題的方法。 看到這一個,
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UILabel *lbl = [[[UILabel alloc] init] autorelease];
lbl.textAlignment = UITextAlignmentLeft;
[email protected]"LHR-SYD/372 Results";
return lbl;
}
通過上述方法可以在不同的對象,你headerview補充。
(OR)
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return @"LHR-SYD/372 Results";
}
這一個你的需求我想是這樣。
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 30;
}
您可以使用此代碼
1
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *transparentView=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,10)];
transparentView.backGroundColor=[UIColor clearColor];
return transparentView;
}
1
這實際上是爲UITableView
的默認標題設置標題視圖的高度。所有你需要做的是實現titleForHeaderInSection
方法,它會出現。查看該方法的文檔,它有幫助很多
0
是的,這是內置的。附加的截圖是UITableView
使用部分。見this tutorial。
您還可以自定義部分標題的視圖。請參閱[tableView:viewForHeaderInSection:]
(http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html)。然而,你看到的是默認視圖,所以你只需要實現部分和titleForHeaderInSection
(見教程)。
2
您可以更改默認的標題視圖BG:
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
header.backgroundView.backgroundColor = [header.backgroundView.backgroundColor colorWithAlphaComponent:1];
}
相關問題
- 1. 固定標題與固體bg顏色和透明bg標誌
- 2. UITableView固定標題
- 3. UITableView透明
- 4. 將固定的透明頭添加到ListView中?
- 5. UITableview:固定節標題
- 6. 定位固定標頭
- 7. 帶固定功能OpenGL的半透明?
- 8. 在固定頭
- 9. CSS標頭固定位置
- 10. 推固定位置標頭
- 11. 如何使JTable的標頭透明
- 12. iPhone上的透明UITableView?
- 13. 不透明的身體背景越過固定標題
- 14. Uisegmentedbar固定在uitableview上方
- 15. 在UITableView中固定的第一行
- 16. CSS:50%透明(透明度)用固態邊境
- 17. 創建透明箭頭
- 18. UITableViewStylePlain與透明報頭
- 19. 透明表格上的透明標籤
- 20. 固定頭
- 21. 固定頭,HTML
- 22. 固定的位置div在iOS6上顯示透明Safari
- 23. WPF不透明蒙板在固定位置
- 24. 透明框在標題
- 25. 假背景透明度/不固定的定位
- 26. 透明PNG在LWJGL中不透明
- 27. 可變高度的固定標頭
- 28. ng-table固定標頭和滾動條
- 29. 用標籤固定分離頭
- 30. 如何創建固定的CSS3標頭?
非常感謝各位的幫助 – user1448401 2013-05-01 10:25:24