2013-07-12 55 views
-1

圖像0​​http://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/Art/keyboard_size.jpg enter image description here 如果你看一下第一個圖像的頂部,谷歌的搜索欄是暗淡的背景之上。我將如何去實現這一目標?如果我做了一個[self.view addSubview]方法,它會出現在變暗的背景下。添加的UIView在暗淡的背景

我發現實現這一目標的一種方法是[[[UIApplication sharedApplication] keyWindow] addSubview:scanView]。我想知道是否有更清潔的解決方案?

謝謝。

+0

你爲什麼要重複你以前的問題? http://stackoverflow.com/questions/17603784/add-uiview-when-keyboard-is-shown-without-being-dimmed-out – rmaddy

回答

0

您可以使用bringSubviewToFront:正確排列視圖。

[parentView bringSubviewToFront:childView]; 

UIView有一些其他的方法也可以用於安排意見是有用的:

  • sendSubviewToBack:
  • insertSubview:atIndex:
  • insertSubview:aboveSubview:
  • insertSubview:belowSubview :
  • exchangeSubviewAtIndex:withSubviewAtIndex:
+0

我在UITextField委託方法'textFieldShouldBeginEditing'上添加子視圖。我希望在用戶點擊UITextField時顯示正確的視圖。這就是當鍵盤顯示和背景變暗時。即使[self.view bringSubviewToFront],它仍然在背景下。有什麼想法嗎? – CLDev

+0

'bringSubviewToFront'應該可以工作。你可以添加你有問題的代碼嗎? – woz