我想为 iPhone 创建一个自定义弹出窗口,它应该如下所示:
为 iPhone 和 iPod 设备实现此功能的最正确方法是什么?
我想为 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];
您可以在单击图标相机时为 Alpha viewPopup 设置动画,例如启用/禁用 viewPopup。
实现您所要求的最简单的方法是创建一个看起来您想要的视图并包含适当的 UIButtons,然后在按下相机按钮时将其添加为子视图(并为其外观设置动画)。尽管 Fonix 对您的问题的评论是正确的,因为操作表旨在用于 iOS 上的此目的。