我想在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. uitableview自定義透明標題
- 2. 需要透明度的固定標題
- 3. 透明固定標題下溢
- 4. 固定標題與固體bg顏色和透明bg標誌
- 5. UITableView固定標題
- 6. UITableView透明
- 7. 將固定的透明頭添加到ListView中?
- 8. 固定標題中的響應式透明標識
- 9. 固定標頭,卡在主固定標頭下面
- 10. 標頭不固定
- 11. UINavigationController透明UITableView下
- 12. UITableview:固定節標題
- 13. 定位固定標頭
- 14. 如何設定明確的背景的UITableView頭與不透明體
- 15. 帶固定功能OpenGL的半透明?
- 16. 在固定頭
- 17. android頭不透明
- 18. 推固定位置標頭
- 19. CSS標頭固定位置
- 20. 固定標頭問題iOS
- 21. 如何使JTable的標頭透明
- 22. iPhone上的透明UITableView?
- 23. 帶透明背景的固定標題CSS奇怪
- 24. 不透明的身體背景越過固定標題
- 25. 具有固定寬度「固定」標頭的居中物體
- 26. Uisegmentedbar固定在uitableview上方
- 27. 透明標籤在標籤
- 28. 帶固定節標題的UITableView
- 29. 實現具有固定標題和固定列的UITableView
- 30. 在UITableView中固定的第一行
非常感謝各位的幫助 – user1448401 2013-05-01 10:25:24