2012-02-22 21 views
0

UITextViewの背後にUIButtonを挿入するのに問題があります。私はボタンを作ることができますし、それは仕事をうまくやっていますが、私が何をしても、それは常にtextViewの前に描画されます。UIButtonビューの背景

- (void)textViewDidBeginEditing:(UITextView *)textView 
{ 
self.backgroundButton = [[UIButton alloc] initWithFrame:self.view.frame]; 
[self.backgroundButton addTarget:textView action:@selector(resignFirstResponder) forControlEvents:UIControlEventTouchDown]; 
[self.view insertSubview:self.backgroundButton aboveSubview:textView]; 
[self.view bringSubviewToFront:textView]; 
} 

答えて

0

はこれを試してみてください。

- (void)textViewDidBeginEditing:(UITextView *)textView 
{ 
self.backgroundButton = [[[UIButton alloc] initWithFrame:self.view.frame] autorelease]; 
[self.backgroundButton addTarget:textView action:@selector(resignFirstResponder) forControlEvents:UIControlEventTouchDown]; 
[self.view insertSubview:self.backgroundButton belowSubview:textView]; 
} 
+0

はまだ動作しません。 :(ボタンはテキストビューの上に描画されます。 を追加すると[self.backgroundButton setBackgroundColor:[UIColor blueColor]]; が表示されます –

関連する問題