Mai*_*r00 9 iphone cocoa-touch objective-c popup ios
我想为iPhone创建一个自定义弹出窗口,如下所示:

为iPhone和iPod设备实现此功能的最正确方法是什么?
Abd*_*que 11
最好的方法是使用UIActionSheet.代码在这里:
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Share" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Facebook",@"Twitter", nil];
[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)
UIActionSheet从底部到顶部,带有一定数量的按钮.您还可以放置一个取消按钮,该按钮将自动关闭UIActionSheet.
以下是它的样子:

有很多方法可供选择.我会亲自做这个代码:
// 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];
Run Code Online (Sandbox Code Playgroud)
单击图标相机(例如启用/禁用viewPopup)时,可以为Alpha viewPopup设置动画.
| 归档时间: |
|
| 查看次数: |
14587 次 |
| 最近记录: |