请检查此链接。我使用actionSheet按照您的要求制作了一个项目。你可以利用这个代码,以供参考,并在项目中嵌入它
https://drive.google.com/open?id=0Bz8kF1Gedr7fd0JzcTh6c0JVMGs
仿佛要增加动作片的高度是你能做到这一点
方法1 - 使用此增加actionSheet高度,增加它
func showAleert(){
let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertControllerStyle.actionSheet) //if you increase actionSheet height to move default button down increase \n \n count and get your layout proper
let margin:CGFloat = 10.0
let rect = CGRect(x: margin, y: margin, width: alertController.view.bounds.size.width - margin * 4.0, height: 320)
let customView = UIView(frame: rect)
customView.backgroundColor = .clear //Background colour as clear
customView.addSubview(buttonn)
customView.addSubview(buttonn1)
customView.addSubview(buttonn2)
customView.addSubview(label)
customView.addSubview(label1)
customView.addSubview(label2)
alertController.view.addSubview(customView)
let ExitAction = UIAlertAction(title: "Go", style: .default, handler: {(alert: UIAlertAction!) in
if self.juiceBool == true {
//go to juice Controller
print("juice")
}
if self.FoodBool == true{
//go to food controller
print("food")
}
if self.FurnitureBool == true{
//go to furniture controller
print("furniture")
}
if (self.juiceBool == false) && (self.FurnitureBool == false) && (self.FoodBool == false){
//peform your operation like naything you want safety side
print("Not selected Any")
}
})
let height:NSLayoutConstraint = NSLayoutConstraint(item: alertController.view, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: self.view.frame.height * 0.80) //here you can define new height for action Sheet
alertController.view.addConstraint(height);
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {(alert: UIAlertAction!) in print("cancel")})
alertController.addAction(ExitAction)
alertController.addAction(cancelAction)
DispatchQueue.main.async {
self.present(alertController, animated: true, completion:{})
}
}
方法2嵌入式的观点高度 - 作为一个视图中添加的是你可以添加滚动视图任何你喜欢的,如果你的选项,则成功更不是像10,30或数量大制作使用方法1,并给予适当的高度,然后在嵌入式视图中添加滚动视图包含多个按钮
或
你可以添加高达10个选项,如果你修改actionSheet使用方法1
这里有一个堆栈关于在警报控制器中放置表视图的问题。 https://stackoverflow.com/a/39253296/5901353 这可能会让你非常接近你正在寻找的东西。试一试,如果您需要进一步的帮助,请用一些代码发布您的问题。 –
使用操作表或使警报 –
@iOSGeek自定义视图任何参考请? – StevenTan