2011-07-16 22 views
1

我想做與移動Safari多頁面模式相同的操作,在先前打開的頁面的右上角的屏幕截圖上顯示一個紅色的x,點擊它關閉它。如何使視圖上的關閉圖標(紅色x)?

我搜索了但找不到任何。它是iOS中的開箱小部件還是我應該自定義的東西?

+1

你可以做一個使用Inkscape或其他一些插圖工具:http://inkscape.org/ –

+0

只要確保你把它放在*左邊*。 – 2011-07-16 01:34:16

+0

@WTP:爲什麼在左邊? – Thilo

回答

3

創建一個與關閉圖標相同的圖像(無法通過公共API獲取它)並將其設置爲UIButton的背景。然後,將其添加爲您網頁的子視圖。完成。

UIButton* closeButton = [[UIButton alloc] 
           initWithFrame:CGRectMake(0.0f, 0.0f, 25.0f, 25.0f)]; 
[closeButton addTarget:self 
       action:@selector(didTapCloseButton:) 
     forControlEvents:UIControlEventTouchUpInside]; 
[closeButton setBackgroundImage:[UIImage imageNamed:@"closeButton.png"] 
         forState:UIControlStateNormal]; 

[self.pageView addSubview:button]; 
[closeButton release];