gpt4 book ai didi

iphone - iOS-模仿系统默认的tableView header

转载 作者:可可西里 更新时间:2023-11-01 05:41:25 25 4
gpt4 key购买 nike

我想以编程方式模仿这个 header 的确切外观: enter image description here

到目前为止,我最好的尝试是:

UILabel* header = [[UILabel alloc] init] ;
header.backgroundColor = [UIColor clearColor];
header.textAlignment = NSTextAlignmentCenter;
header.textColor = [[UIColor alloc] initWithRed:86 green:92 blue:112 alpha:0.1];
header.shadowColor = [UIColor darkGrayColor];
header.shadowOffset = CGSizeMake(1,0);
header.font = [UIFont boldSystemFontOfSize:18];

但它看起来像这样: enter image description here

有人可以帮我知 Prop 体的方法吗?

提前致谢!

最佳答案

不久前,一位挪威人写了一篇关于此的博文:http://www.gersh.no/posts/view/default_styling_of_sections_headers_in_uitableview_grouped

enter image description here

代码的所有功劳都归于他。

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
containerView.backgroundColor = [UIColor groupTableViewBackgroundColor];
CGRect labelFrame = CGRectMake(20, 2, 320, 30);
if(section == 0) {
labelFrame.origin.y = 13;
}
UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:17];
label.shadowColor = [UIColor colorWithWhite:1.0 alpha:1];
label.shadowOffset = CGSizeMake(0, 1);
label.textColor = [UIColor colorWithRed:0.265 green:0.294 blue:0.367 alpha:1.000];
label.text = [self tableView:tableView titleForHeaderInSection:section];
[containerView addSubview:label];
return containerView;
}

关于iphone - iOS-模仿系统默认的tableView header,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18737517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com