我想在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