ビューの clipsToBounds プロパティを NO に設定すると、ビューが独自のフレームの外に描画できるようになります。
UITableViewController サブクラスで:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do what you normally do here, if anything then add...
self.view.clipsToBounds = NO;
}
これを行うと、部分的にスクロールして表示されるのではなく、テーブルビューの下部または上部に完全なセルが作成されるという副作用があります。clipsToBounds が YES に設定されている別のビューにテーブル ビューを配置するか、テーブル ビューの端を画面の端に揃えるか、ビューが上下を覆うようにします (UIToolbar と UINavigationBar が通常行うように)。
UITableViewCell の selectedBackgroundView をテーブル ビューのフレームを超えて拡張するには、UITableViewCell のサブクラスを作成し、layoutSubviews メソッドをオーバーライドします。
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"YQGyZ"]];
self.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CQXYh"]];
self.textLabel.backgroundColor = [UIColor clearColor];
self.detailTextLabel.backgroundColor = [UIColor clearColor];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGRect frame = self.selectedBackgroundView.frame;
frame.size.width += 13; // where 13 is the size of the arrow overhang from the same images
self.selectedBackgroundView.frame = frame;
// You can also change the location of the default labels (set their background colors to clear to see the background under them)
self.textLabel.frame = CGRectMake(70, 0, 148, 30);
self.detailTextLabel.frame = CGRectMake(70, 30, 148, 30);
}
幸運を。