Default section head title font & color and so on
来源:互联网 发布:plc编程软件安装不了 编辑:程序博客网 时间:2024/06/05 00:26
参考:
[1]http://stackoverflow.com/questions/5869344/uitableview-header-footer-font-color
[2]http://www.iphonedevsdk.com/forum/iphone-sdk-development/1199-default-tableview-section-header-background-color.html
UITableview可以由多个Section组成,每个section可以由若干个row,并且可以为section设置title标题,可以用来设置标题。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; // fixed font style. use custom view (UILabel) if you want something different这是个UITableViewDataSource的回调函数,当显示完成后,除非你roloadData,而roloadData会带来性能花费, 否则不会重新调用。因此,你也不能对实时的改变title。
这时可以通过返回一个view给Section head,这样你就可以addsubview显示任何你想显示的,并且将此view做为实例成员,就可以做到实时改变,而不需要reloadData。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; // custom view for header. will be adjusted to default or specified header height
但有个问题,你如何使显示的section 标题,跟通过titleForHeaderInSection回调显示的一样,就是你不清楚它所用的字体、颜色、等等信息。所以要想显示的跟系统一样就需要以下信息
Plain
fontName: Helvetica-Bold
pointSize: 18.000000
textColor: UIDeviceWhiteColorSpace 1 1
shadowColor: UIDeviceWhiteColorSpace 0 0.44
shadowOffset: CGSize 0 1
Grouped
fontName: Helvetica-Bold
pointSize: 17.000000
textColor: UIDeviceRGBColorSpace 0.298039 0.337255 0.423529 1
shadowColor: UIDeviceWhiteColorSpace 1 1
shadowOffset: CGSize 0 1
我用到的相关代码如下:
UILabel* sectionHeadLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 320, 44)];sectionHeadLabel.backgroundColor = [UIColor clearColor];sectionHeadLabel.textColor = [UIColor colorWithRed:0.298039 green:0.337255 blue:0.423529 alpha:1.0]; sectionHeadLabel.shadowColor = [UIColor colorWithWhite:1.0 alpha:1.0];sectionHeadLabel.shadowOffset = CGSizeMake(0, 1); sectionHeadLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0f];
- Default section head title font & color and so on
- font , color and Auto-mode customization
- R.string.ID 返回的是int 而不是 string(layout, color,drawable and so on)
- Elva and so on
- Color & Font
- Set the color and font of a GtkLabel
- Change the font and cell color in an Excel document
- Set font size and color in GUI.Label
- copy_from_user | copy_to_user and so on
- MVC模式and so on
- error,Debug,and so on
- onmouse onkeypress and so on
- SVD, PCA and so on
- ruby on rails and so on
- Elliptical Head Tracking Using Intensity Gradients and Color Histograms(1998)
- css-font-color例子
- VC VC++ VB UG and so on
- [gstreamer][001] Seek issues and so on
- 20110111
- file_operations数据结构分析
- jQuery插件开发全解析
- 开源学习总贴
- 装饰模式:类的组合调用
- Default section head title font & color and so on
- PostgreSQL启动过程中的那些事七:初始化共享内存和信号:四 shmem中初始化subtrans
- struts.xml配置详解
- 代理模式
- 恢复Active Desktop
- android中sqlite的query中的String[]造成sql畸形
- 用autotools制作Makefile 和configure文件
- 【完全二分匹配必须边】POJ 1486
- 使用进程加载应用程序