0

UITextView のレイヤーの影を UITableView ヘッダーで動作させようとしています。私はすべてをフォーマットしているUIViewを持っており、headerviewをそれに等しく設定しています。

UIView * view = [[UIView alloc] initWithFrame: CGRectMake(0, 0, self.tableView.frame.size.width, 450);
UIColor * baseColor = [[UIColor alloc] initWithRed: 45/255.0
                                             green: 100/255.0
                                              blue: 150/255.0
                                             alpha: 1.0];

view.backgroundColor = baseColor;
...
UITextView * newCommentField = [[UITextView alloc] initWithFrame:CGRectMake(20, 230, 270,   120)];
newCommentField.text = @"New Comment";
newCommentField.tag = 3;
newCommentField.layer.shadowOffset = CGSizeMake(0, 3);
newCommentField.layer.shadowRadius = 5.0;
newCommentField.layer.shadowColor = [UIColor blackColor].CGColor;
newCommentField.layer.shadowOpacity = 0.8;
[view addSubview:newCommentField];
...
self.tableView.tableHeaderView = view;

すべてがビューに正しく表示されます。ただし、影は表示されません。ここで何が問題なのかわかりません。レイヤーのフレームを変更して、コメント フィールドのサイズを大きくして同じサイズにすることさえ試みました。

4

2 に答える 2

1

newCommentField の背景色を設定していません。試す:

newCommentField.backgroundColor = [UIColor whiteColor];
于 2016-07-27T03:13:11.380 に答える