var sheet: UIActionSheet = UIActionSheet()
sheet.title = "Report this member?"
sheet.delegate = self
sheet.tag = 1
sheet.addButtonWithTitle("Cancel")
sheet.addButtonWithTitle("Report")
sheet.cancelButtonIndex = 0
sheet.showInView(self.view)
我希望"报告"为红色,取消为灰色。
有没有特定的方法来做到这一点?
您可以提供此服务,创建自定义按钮,将它们添加为子视图
var sheet: UIActionSheet = UIActionSheet()
sheet.title = "Report this member?"
var btn:UIButton = UIButton()
btn.setTitle("Cancel", forState: UIControlState.Normal)
btn.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
btn.backgroundColor = UIColor.grayColor()
btn.addTarget(self, action: "pressCancel", forControlEvents: UIControlEvents.TouchDown)
sheet.addSubview(btn)
var btn1:UIButton = UIButton()
btn1.setTitle("Report", forState: UIControlState.Normal)
btn1.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
btn1.backgroundColor = UIColor.redColor()
btn1.addTarget(self, action: "pressReport", forControlEvents: UIControlEvents.TouchDown)
sheet.addSubview(btn1)