簡體   English   中英

如何為iPhone創建自定義彈出窗口?

[英]How can I create a custom popup window for iPhone?

我想為iPhone創建一個自定義彈出窗口,如下所示: 在此輸入圖像描述

為iPhone和iPod設備實現此功能的最正確方法是什么?

最好的方法是使用UIActionSheet。 代碼在這里:

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Share" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Facebook",@"Twitter", nil];
[actionSheet showInView:self.view];

UIActionSheet從底部到頂部,帶有一定數量的按鈕。 您還可以放置一個取消按鈕,該按鈕將自動關閉UIActionSheet。

以下是它的樣子:

在此輸入圖像描述

您應該嘗試自定義彈出窗口的第三方類。 一些如下

1.) CMPopTipView
2.) KBPopupBubble
3.) ADPopupView

使用第三方控件,執行此操作。

是您可以下載此項目的鏈接。

有很多方法可供選擇。 我會親自做這個代碼:

// create view popup
UIView *viewPopup = [[UIView alloc] initWithFrame:CGRectMake(x, y, width, height)];
[self.view addSubview:viewPopup];

// create Image View with image back (your blue cloud)
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];
UIImage *image =  [UIImage imageNamed:[NSString stringWithFormat:@"myImage.png"]];
[imageView setImage:image];
[viewPopup addSubview:imageView];

// create button into viewPopup
UIButton *buttonTakePhoto = [[UIButton alloc] initWithFrame:CGRectMake(x, y, width, height)];
[viewPopup addSubview: buttonTakePhoto];
[buttonTakePhoto setTitle:@"Take Photo" forState:UIControlStateNormal];
[buttonTakePhoto addTarget:self action:@selector(actionTakePhoto) forControlEvents:UIControlEventTouchDown];
[viewPopup addSubview:buttonTakePhoto];

單擊圖標相機(例如啟用/禁用viewPopup)時,可以為Alpha viewPopup設置動畫。

實現所要求的最簡單方法是創建一個看起來如何的視圖,並包含相應的UIButtons,然后在按下相機按鈕時將其添加為子視圖(並按照您想要的方式設置它的外觀)。 雖然Fonix對您的問題的評論是正確的,因為操作表旨在用於iOS上的此目的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM