私はあなたがこれを簡単に行うことができませんほぼ確実です。私は最近、私の開発サポートアカウントの技術サポートリクエストの1つを使用して、UITableViewセクションの背景と境界の変更について最近質問しました。アップルのエンジニアは、これは本当に簡単なことではないと言いました。あなたがそれをやったとしても、パフォーマンスにはおそらく影響します。彼はまたcocoawithloveに私を指摘し、編集uitableviews記事:
http://cocoawithlove.com/2009/08/adding-shadow-effects-to-uitableview.html
本当に、あなた自身のヘッダを作成すると、その多くの努力ではありません。それがコメントアウトされたので、すぐに動作しない可能性があります - - 以下は、私は私のプロジェクトの1から引き出されたいくつかのコードですが、あなたのアイデアを得ることができます。
- (CAGradientLayer *) greyGradient {
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.startPoint = CGPointMake(0.5, 0.0);
gradient.endPoint = CGPointMake(0.5, 1.0);
UIColor *color1 = [UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:1.0];
UIColor *color2 = [UIColor colorWithRed:240.0f/255.0f green:240.0f/255.0f blue:240.0f/255.0f alpha:1.0];
[gradient setColors:[NSArray arrayWithObjects:(id)color1.CGColor, (id)color2.CGColor, nil]];
return gradient;
}
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGFloat width = CGRectGetWidth(tableView.bounds);
CGFloat height = [self tableView:tableView heightForHeaderInSection:section];
UIView *container = [[[UIView alloc] initWithFrame:CGRectMake(0,0,width,height)] autorelease];
container.layer.borderColor = [UIColor grayColor].CGColor;
container.layer.borderWidth = 1.0f;
CAGradientLayer *gradient = [self greyGradient];
gradient.frame = container.bounds;
[container.layer addSublayer:gradient];
UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(12,0,width,height)] autorelease];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.font= [UIFont boldSystemFontOfSize:19.0f];
headerLabel.shadowOffset = CGSizeMake(1, 1);
headerLabel.textColor = [UIColor whiteColor];
headerLabel.shadowColor = [UIColor darkGrayColor];
NSString *title = [self tableView:tableView titleForHeaderInSection:section];
headerLabel.text = title;
return container;
}
#import <QuartzCore/QuartzCore.h>
によって確認してください方法は...これは標準ヘッダーの外観を模倣するものではありません - その単なる例です。しかし、私は少し試行錯誤して、標準のものを模倣して色を少し変えることができると確信しています。
テキストに何かが見つからないようです。#import what?おそらくいくつかのコアアニメーションのものでしょうか? – Thorsten
ああ、CAGradientLayerを使用したのはQuartzCoreでした。ポストに追加します。ありがとう – bandejapaisa
また、[container addSubview:headerLabel]が見つからない場合は、このようなことをすれば本当に良いでしょう。 \t CGFloat width = tableView.bounds.size.width; \t CGFloatの高さ= [self tableView:tableView heightForHeaderInSection:section]; UIView * container = [[UIView alloc] initWithFrame:CGRectMake(0,0、width、height)]; –